Skip to content

Introduced ignore attribute to JsonKey. #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 72 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
9f3a944
Support the latest pkg/build packages (#62)
kevmoo Nov 2, 2017
c181095
Fix ensure_build_test
kevmoo Nov 2, 2017
5ee8652
prepare json_annonation for release
kevmoo Nov 2, 2017
9e0f70c
json_serializable: prepare for release (#64)
kevmoo Nov 2, 2017
c820d01
Fix non-nullable generated library name, keep class name consistent
kevmoo Oct 31, 2017
7601847
fix test names
kevmoo Oct 29, 2017
ac8da41
cleanup to JsonSerializableGenerator
kevmoo Oct 29, 2017
73f7666
build_actions: be explicit about where the generator is run
kevmoo Oct 31, 2017
027f5c7
Fix reference to bathtub
kevmoo Oct 31, 2017
3129d78
Make non-nullable flavor of json test examples
kevmoo Nov 3, 2017
655130c
Consider both `nullable` and `includeIfNull` when writing serialization
kevmoo Nov 3, 2017
29437f0
Improve error message when a field cannot be (de)serialized
kevmoo Nov 1, 2017
328e6b3
test: Cleanup kitchen_sink Classes and generation
kevmoo Nov 3, 2017
a9cde3e
Missed a dartfmt (#69)
kevmoo Nov 3, 2017
a04afe5
Improve error message when a field cannot be (de)serialized
kevmoo Nov 1, 2017
ae1b066
Remove deprecated `annotations.dart` library
kevmoo Nov 3, 2017
9e968f5
Update to latest build_runner - with fix for checked mode
kevmoo Nov 3, 2017
59d12bf
Support generating a custom map and using non-copying wrappers for se…
kevmoo Nov 23, 2017
1cc06c8
Pass field metadata to type helpers (#76)
sasha-caleo Nov 25, 2017
a0be252
Follow-up cleanup (#77)
kevmoo Nov 27, 2017
3d7783b
allow optional parameters for types using fromJson() (#72)
johnpryan Nov 27, 2017
b42481b
fix dartfmt (#78)
kevmoo Nov 27, 2017
5b51d59
Remove accidental file
kevmoo Dec 13, 2017
769a54c
Creating a stand-alone example (#80)
kevmoo Dec 14, 2017
d1328fd
Fix up links between readmes/sub-packages
kevmoo Dec 15, 2017
a88f315
example: Comment pubspec.yaml – and add a constraint on pkg/build_runner
kevmoo Dec 15, 2017
2c40819
example: improve build_action docs and cleanup example_test.dart
kevmoo Dec 15, 2017
6697ef9
example: improve readme documentation...
kevmoo Dec 15, 2017
1bf4a3e
Example: remove dependency overrides in example/pubspec.yaml
kevmoo Dec 15, 2017
b54d0e6
Add new library: json_serializable.dart
kevmoo Dec 15, 2017
68fabf5
Prepare to release json_annotation (#86)
kevmoo Dec 15, 2017
039b8da
Prepare to release json_serializable 0.3.0 (#87)
kevmoo Dec 15, 2017
aa0d37c
example: update to json_serializable 0.3.0 (#88)
kevmoo Dec 15, 2017
7e3ed93
Upgrade to build_runner 0.7 (#90)
natebosch Jan 2, 2018
ca62b63
Add requireLibraryDirective parameter to jsonPartBuilder (#91)
kevmoo Jan 3, 2018
374a55d
Prepare to release v0.3.1 (#93)
kevmoo Jan 4, 2018
71b9f0c
example: update for shipped json_serializable (#94)
kevmoo Jan 4, 2018
a9fed27
support package:build version 0.12.0 (#96)
jakemac53 Jan 18, 2018
11c7ff5
Unpin dev SDK in travis (#97)
kevmoo Jan 19, 2018
7dba2c6
Don't run tests against json_serializable on stable
kevmoo Feb 3, 2018
066e957
Support the latest version of pkg/analyzer
kevmoo Feb 3, 2018
423377d
use latest mono_repo (#99)
kevmoo Feb 7, 2018
023d15d
example: cleanup
kevmoo Feb 10, 2018
1517c9e
Ignore deprecated usage of requireLibraryDirective - for now
kevmoo Feb 10, 2018
a6cc5b4
one-off dartfmt
kevmoo Feb 10, 2018
65b7bcd
Change require library directive default (#102)
kevmoo Feb 12, 2018
f1695ea
Update example to use latest (#103)
kevmoo Feb 12, 2018
1bc90a0
Enable unnecessary_brace_in_string_interps lint
kevmoo Feb 15, 2018
35ce0e9
Add Map<String, Enum> to test cases
kevmoo Feb 15, 2018
3c81c1f
Avoid unnecessary braces in string escapes
kevmoo Feb 15, 2018
b6ffbce
Use single quotes when generating code.
kevmoo Feb 15, 2018
86dc274
Add missing copyright headers
kevmoo Feb 15, 2018
ba55f93
Move test Dart code for json_serializable_test to a dart file (#106)
kevmoo Feb 21, 2018
eced4db
Support inherited fields (#107)
kevmoo Feb 23, 2018
e42346c
Prepare to release 0.4.0 (#108)
kevmoo Feb 23, 2018
31cf5ae
Update example to latest pkg:json_serializable (#109)
kevmoo Feb 28, 2018
eed6d38
Introduced ignore attribute to JsonKey. When set to true the generato…
AlexanderJohr Mar 8, 2018
469a8ed
Add repository LICENSE file
kevmoo Mar 12, 2018
5fce9ac
Move from JSON -> json
kevmoo Mar 12, 2018
d754ef8
Fix test expectations for recent pkg:build versions
kevmoo Mar 12, 2018
495c5a6
Merge branch 'master' into ignore-private-and-ignore-annotated-fields
AlexanderJohr Mar 12, 2018
8b42ec5
Added dependency_overrides for json_annotation to get the latest anno…
AlexanderJohr Mar 13, 2018
b6b70da
Merge branch 'ignore-private-and-ignore-annotated-fields' of https://…
AlexanderJohr Mar 13, 2018
d402b40
Changed return type of _writeFactory to void
AlexanderJohr Mar 13, 2018
a8bbb86
Latest pkg:build_runner
kevmoo Mar 16, 2018
33707a5
Serial/Deserial context metadata - readonly
kevmoo Mar 16, 2018
4925722
Enable and fix many more lints
kevmoo Mar 16, 2018
9240774
Refactored _writeFactory to return the fields that were used to set, …
AlexanderJohr Mar 17, 2018
739ac61
added test "works to ignore a field"
AlexanderJohr Mar 17, 2018
bb77bd2
Added test 'includes final field in toJson when set in ctor' which en…
AlexanderJohr Mar 17, 2018
88b14ed
Ran dart formatter on json_serializable_test_input.dart
AlexanderJohr Mar 20, 2018
75f85f2
Merge branch 'master' into ignore-private-and-ignore-annotated-fields
AlexanderJohr Mar 21, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 47 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,57 @@
# Created with https://github.com/dart-lang/mono_repo
language: dart

dart:
- dev
- stable
jobs:
include:
- stage: analyzer_and_format
script: ./tool/travis.sh dartfmt
env: PKG="example"
dart: dev
- stage: analyzer_and_format
script: ./tool/travis.sh dartanalyzer
env: PKG="example"
dart: dev
- stage: unit_test
script: ./tool/travis.sh test
env: PKG="example"
dart: dev
- stage: analyzer_and_format
script: ./tool/travis.sh dartfmt
env: PKG="json_annotation"
dart: dev
- stage: analyzer_and_format
script: ./tool/travis.sh dartfmt
env: PKG="json_annotation"
dart: stable
- stage: analyzer_and_format
script: ./tool/travis.sh dartanalyzer
env: PKG="json_annotation"
dart: dev
- stage: analyzer_and_format
script: ./tool/travis.sh dartanalyzer
env: PKG="json_annotation"
dart: stable
- stage: analyzer_and_format
script: ./tool/travis.sh dartfmt
env: PKG="json_serializable"
dart: dev
- stage: analyzer_and_format
script: ./tool/travis.sh dartanalyzer
env: PKG="json_serializable"
dart: dev
- stage: unit_test
script: ./tool/travis.sh test
env: PKG="json_serializable"
dart: dev

env:
- PKG=json_annotation TASK=dartanalyzer
- PKG=json_annotation TASK=dartfmt
- PKG=json_serializable TASK=dartanalyzer
- PKG=json_serializable TASK=dartfmt
- PKG=json_serializable TASK=test

matrix:
exclude:
- dart: stable
env: PKG=json_serializable TASK=dartanalyzer
- dart: stable
env: PKG=json_serializable TASK=dartfmt

script: ./tool/travis.sh
stages:
- analyzer_and_format
- unit_test

# Only building master means that we don't run two builds for each pull request.
branches:
only: [master]

cache:
directories:
- $HOME/.pub-cache
directories:
- $HOME/.pub-cache
26 changes: 26 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright 2017, the Dart project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
# [![Build Status](https://travis-ci.org/dart-lang/json_serializable.svg?branch=master)](https://travis-ci.org/dart-lang/json_serializable)

Provides `source_gen` `Generator`s which generate code to
make it simple to serialize to and from JSON.
Provides [source_gen] `Generator`s to create code for JSON serialization and
deserialization.

## [json_serializable]
## json_serializable

* Package: https://pub.dartlang.org/packages/json_serializable
* [Source code](json_serializable)

The core package providing Generators for JSON-specific tasks.

Import it into your pubspec `dev_dependencies:` section.

## [json_annotation]
## json_annotation

* Package: https://pub.dartlang.org/packages/json_annotation
* [Source code](json_annotation)

The annotation package which has no dependencies.

Import it into your pubspec `dependencies:` section.

[json_serializable]: https://github.com/dart-lang/json_serializable/blob/master/json_serializable/README.md
[json_annotation]: https://github.com/dart-lang/json_serializable/blob/master/json_annotation/README.md
## example

* [Source code](example)

An example showing how to setup and use `json_serializable` and
`json_annotation`.

[source_gen]: https://pub.dartlang.org/packages/source_gen
58 changes: 45 additions & 13 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,65 @@ analyzer:
dead_code: error
linter:
rules:
# Errors
- avoid_empty_else
- comment_references
- control_flow_in_finally
- empty_statements
- hash_and_equals
- implementation_imports
- test_types_in_equals
- throw_in_finally
- unrelated_type_equality_checks
- valid_regexps

# Style
- annotate_overrides
- avoid_empty_else
- avoid_function_literals_in_foreach_calls
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
- avoid_return_types_on_setters
- avoid_returning_null
- avoid_unused_constructor_parameters
- await_only_futures
- camel_case_types
- cancel_subscriptions
#- cascade_invocations
- comment_references
- constant_identifier_names
- control_flow_in_finally
- directives_ordering
- empty_catches
- empty_constructor_bodies
- empty_statements
- hash_and_equals
- implementation_imports
- invariant_booleans
- iterable_contains_unrelated_type
- library_names
- library_prefixes
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names
- omit_local_variable_types
- only_throw_errors
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_adjacent_string_concatenation
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_contains
- prefer_final_fields
- prefer_initializing_formals
- prefer_interpolation_to_compose_strings
- prefer_is_empty
- prefer_is_not_empty
- prefer_single_quotes
- prefer_typing_uninitialized_variables
- recursive_getters
- slash_for_doc_comments
- super_goes_last
- test_types_in_equals
- throw_in_finally
- type_init_formals
- unawaited_futures
- unnecessary_brace_in_string_interps
- unnecessary_getters_setters
- unnecessary_lambdas
- unnecessary_null_aware_assignments
- unnecessary_statements
- unnecessary_this
- unrelated_type_equality_checks
- valid_regexps
5 changes: 5 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Files and directories created by pub
.packages
.pub/
build/
pubspec.lock
11 changes: 11 additions & 0 deletions example/.mono_repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# See https://github.com/dart-lang/mono_repo for details
dart:
- dev

stages:
- analyzer_and_format:
- dartfmt
- dartanalyzer: --fatal-infos --fatal-warnings .
- unit_test:
# Run the tests -- include the default-skipped presubmit tests
- test: --run-skipped
48 changes: 48 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
*This example assumes you're using a recent version of the Dart or Flutter SDK.*

* Dart: you need a [v2 pre-release](https://www.dartlang.org/dart-2).
* Flutter: at least 0.0.23 (Feb 5, 2018).

To use [package:json_serializable][json_serializable] in your package, add these
dependencies to your `pubspec.yaml`.

```yaml
dependencies:
json_annotation: ^0.2.2

dev_dependencies:
build_runner: ^0.7.6
json_serializable: ^0.4.0
```

Annotate your code with classes defined in
[package:json_annotation][json_annotation].

* See [`lib/example.dart`][example] for an example of a file using these
annotations.

* See [`lib/example.g.dart`][example_g] for the generated file.

If you would like to use a custom header, or enable the wrapper option, add a
[`build.yaml`][build_config] file and a default target.

Run `pub run build_runner build` to generate files into your source directory.

```console
> pub run build_runner build
[INFO] ensureBuildScript: Generating build script completed, took 368ms
[INFO] BuildDefinition: Reading cached asset graph completed, took 54ms
[INFO] BuildDefinition: Checking for updates since last build completed, took 663ms
[INFO] Build: Running build completed, took 10ms
[INFO] Build: Caching finalized dependency graph completed, took 44ms
[INFO] Build: Succeeded after 4687ms with 1 outputs
```

*NOTE*: If you're using Flutter, running a script from a Dart package is a bit
tricky. Replace `pub run` with `flutter packages pub run`.

[example]: lib/example.dart
[example_g]: lib/example.g.dart
[build_config]: build.yaml
[json_annotation]: https://pub.dartlang.org/packages/json_annotation
[json_serializable]: https://pub.dartlang.org/packages/json_serializable
13 changes: 13 additions & 0 deletions example/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Read about `build.yaml` at https://pub.dartlang.org/packages/build_config
targets:
$default:
builders:
json_serializable:
options:
header: |+
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// GENERATED CODE - DO NOT MODIFY BY HAND

3 changes: 3 additions & 0 deletions example/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tags:
presubmit-only:
skip: "Should only be run during presubmit"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.

// ignore_for_file: annotate_overrides
library json_serializable.example;

import 'package:json_annotation/json_annotation.dart';
part 'example.g.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// GENERATED CODE - DO NOT MODIFY BY HAND

part of json_serializable.example;
part of 'example.dart';

// **************************************************************************
// Generator: JsonSerializableGenerator
Expand Down
16 changes: 16 additions & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: example
author: Dart Team <misc@dartlang.org>

environment:
sdk: '>=2.0.0-dev.9 <2.0.0'

dependencies:
json_annotation: ^0.2.2

dev_dependencies:
build_runner: ^0.7.6
json_serializable: ^0.4.0

# Used by tests. Not required to use `json_serializable`.
path: ^1.5.1
test: ^0.12.29
Loading