Comments (9)
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.
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.
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.
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.
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.
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.
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.
The link should be https://github.com/google/built_value.dart
from built_collection.dart.
That's right. Thanks :)
from built_collection.dart.
Related Issues (20)
- Serializers spread across projects? HOT 8
- Serializing a Map without using specifiedType HOT 3
- BuiltList serialization seems to require specifiedType HOT 3
- Release for inference change HOT 1
- Add const BuiltList<T>.empty() HOT 6
- Add ListBuilder.indexOf HOT 1
- Allow BuiltList<T?> HOT 2
- BuiltList first & elementAt should be nullable HOT 3
- Custom serializer for BuiltMap HOT 1
- Tighten generics HOT 2
- Use `@checkResult` annotation
- Cannot rebuild a BuiltSet entry in BuiltMap HOT 7
- (Question) how to rebuild every value in BuiltList? HOT 1
- Why is the return operator[] on BuiltSetMultimap nullable?
- Docs for `asList` misleading
- Unable to update nested BuiltList inside ListBuilder HOT 5
- [Feature Request/ Question] Native Support for json_serializable / json_annotation HOT 3
- Found 1 file excluded from sound null safety HOT 1
- Shouldn't BuiltMap<String, BuiltSet<int>> work out of the box? HOT 9
- BuiltMap.containsKey should accept `Object?` 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 built_collection.dart.