Comments (7)
IΒ΄ve tried what you suggested, and it works.
So the problem is that when you add annotation options, the builder doesnΒ΄t care about them until the @JsonSerializable()
is removed from the class and added again?
Anyways, thanks alot!
By the way, it would be nice if you could call initializeJsonMapper()
with some default options, like ignoreNullMembers
- but that is a detail. Thanks alot for an awesome project, itΒ΄s a great help!
from dart-json-mapper.
As far as I can see, you cannot set default annotations like this, for all classes, is that correct?
yep, for global context you have SerializationOptions
, for local context individual annotations.
I'll check this case and let you know what's wrong with it. Seems legit case for me
from dart-json-mapper.
Well, here is a unit test which is covering this functionality.
and it's green πHighly probably you've not regenerated the code after altering
@Json(ignoreNullMembers: true)
annotation.
To force full regeneration cycle, you can:
- comment out any
@JsonSerializable()
annotation, switch your keyboard focus on the console running build runner - wait till build runner finishes it's pass
- un-comment
@JsonSerializable()
annotation back and wait till build runner will succeeds
Usually to save on coding performance, code is not fully regenerated while you are typing. The only thing sensible is the presence/absence of @JsonSerializable()
/ @jsonSerializable
annotation
from dart-json-mapper.
Thanks for the suggestion, makes sense to me. I'll take it as improvement π
from dart-json-mapper.
Cool π»π
from dart-json-mapper.
@fasterlars Since 2.2.6+1
initializeJsonMapper()
accepts global serialization/deserialization options. That's actually saved me a lot of redundant code in unit tests well done π through the years I've not noticed such a straight forward move π
from dart-json-mapper.
Haha, awesome! π
from dart-json-mapper.
Related Issues (20)
- Flutter Json Mapper (json_mapper) is failing to deserialize Enum HOT 1
- Cannot deserialize to a class with a constructor that takes an enum HOT 4
- Can't add sources to `build.yaml` using `flutter_translate_annotations` package HOT 7
- ignoreNullMembers seems to break the deserialization HOT 2
- Problem converting enum with following uppercase character HOT 9
- Adapter for https://pub.dev/packages/fast_immutable_collections
- `main.mapper.g.dart` is not generating all `@jsonSerializable` classes HOT 6
- `JsonMapper.copyWith` doesn't respect deep merge
- Parsing error when building for web HOT 9
- Improve class instance creation error handling HOT 4
- Problem converting enum with following uppercase character - second edition :) HOT 10
- Omit serializing optional fields HOT 14
- Issues with deserialising Color HOT 3
- Dart Json Mapper looks like don't generate valueDecorators when models in different package HOT 1
- Default discriminatorValue may not work. HOT 4
- Using with Retrofit HOT 2
- Serialize generic type. HOT 1
- @Json takes no effect even if put on top class & processAnnotatedMembersOnly in option will ignore all members when serialization HOT 1
- Empty Reflectable file - regarding HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dart-json-mapper.