Git Product home page Git Product logo

Comments (9)

davidmorgan avatar davidmorgan commented on May 1, 2024

Conversion to/from JSON is intended to be via:

https://github.com/google/built_json.dart

Are there cases where toJson would be more helpful? I'm hesitant about supporting an alternative way of serializing unless it adds something.

from built_collection.dart.

Andersmholmgren avatar Andersmholmgren commented on May 1, 2024

I know what you mean about supporting multiple json serialisation methods. Not ideal.

Sadly I think it is the name of a single method that prevents it working - BuiltMap's toMap rather than toJson.

I think the other built collection classes are ok thanks to implementing Iterable.

core dart really needs a map equivalent of Iterable that both Map and BuiltMap could implement.

I haven't looked at built_json yet. At this stage I am only using built collection. I didn't realise at the time that buying into built_collection meant buying into a different json serialisation mechanism.

from built_collection.dart.

davidmorgan avatar davidmorgan commented on May 1, 2024

It can certainly be added if it's useful. Feel free to send a pull request, or I'll get around to it at some point.

I'm not sure how people actually use toJson -- how do you deserialize, for example?

from built_collection.dart.

Andersmholmgren avatar Andersmholmgren commented on May 1, 2024

Cool. Thanks will send a pr soon.

Deserialisation is done via a fromJson ctr. These are called after JSON decode so take JSON primitives like maps.

In the case of BuiltMap that would essentially be an alias for one of the existing structures.

For the record I'm not a missive fan of the "standard" dart mechanism for handling JSON but having some sort of standard adds some value.

I support it in the frameworks that I maintain like shelf_bind for that reason as others do such as the source_gen package that Kev Moore et al are working on.

from built_collection.dart.

davidmorgan avatar davidmorgan commented on May 1, 2024

Hum. How does deserialization know whether to call BuiltMap.fromJson as
opposed to some other classes's fromJson? Or do you have to do that by hand?

Thanks.

On Mon, 11 Apr 2016 at 15:48 Andersmholmgren [email protected]
wrote:

Cool. Thanks will send a pr soon.

Deserialisation is done via a fromJson ctr. These are called after JSON
decode so take JSON primitives like maps.

In the case of BuiltMap that would essentially be an alias for one of the
existing structures.

For the record I'm not a missive fan of the "standard" dart mechanism for
handling JSON but having some sort of standard adds some value.

I support it in the frameworks that I maintain like shelf_bind for that
reason as others do such as the source_gen package that Kev Moore et al are
working on.


You are receiving this because you commented.

Reply to this email directly or view it on GitHub
#57 (comment)

from built_collection.dart.

Andersmholmgren avatar Andersmholmgren commented on May 1, 2024

Derp. Good point. It doesn't which means a fromJson Ctr is pointless for BuiltMap. Really just the toJson that's useful

from built_collection.dart.

davidmorgan avatar davidmorgan commented on May 1, 2024

The way to serialize is now to use

http://github.com/google/built_value

-- I think other changes are probably not needed. Closing.

from built_collection.dart.

zoechi avatar zoechi commented on May 1, 2024

The link should be https://github.com/google/built_value.dart

from built_collection.dart.

davidmorgan avatar davidmorgan commented on May 1, 2024

That's right. Thanks :)

from built_collection.dart.

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.