Coder Social home page Coder Social logo

Comments (7)

Lars-Sommer avatar Lars-Sommer commented on June 3, 2024 2

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.

k-paxian avatar k-paxian commented on June 3, 2024 1

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.

k-paxian avatar k-paxian commented on June 3, 2024

Well, here is a unit test which is covering this functionality.

test('IgnoreNullMembers class', () {
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.

k-paxian avatar k-paxian commented on June 3, 2024

Thanks for the suggestion, makes sense to me. I'll take it as improvement πŸ˜‰

from dart-json-mapper.

Lars-Sommer avatar Lars-Sommer commented on June 3, 2024

Cool 🍻😊

from dart-json-mapper.

k-paxian avatar k-paxian commented on June 3, 2024

@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.

Lars-Sommer avatar Lars-Sommer commented on June 3, 2024

Haha, awesome! πŸ‘

from dart-json-mapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.