Nicer deserializer format #7
Comments
Not sure exactly what you are referring to here. I'm looking for a serializer format that is more the typical looking json formatting. My current use case is that I am building Of course for interoperability with external sources of JSON this is needed too. If this is not what you are referring to then I'll likely need to look at building something. In which case I'd like your thoughts on whether it makes sense to leverage the code in this repo or not |
This issue is just about how the generated code works. Re: the wire format itself, it's designed for use in RPCs. It's unlikely to match any other specific format. Although, if there's an existing format that happens to cover what's needed, we could switch. One consideration for example is whether to use a map from field name to field value. This looks nicer. But, it's a lot more expensive than an array, in memory and performance. So in this context arrays are better. |
Yeah makes sense for RPCs if you control both ends of the channel. In many cases you don't though and the map based way seems to be the norm. I'll play around with generating some Codecs |
Right. I would be fine with supporting multiple formats; if it's an option at code generation time then this wouldn't add any runtime/compile overhead. But there'd need to be a clear use case for each format, of course. Could you point to a specification of the format you're interested in, please? |
Not sure what you are after in terms of specifications. If you mean a spec for how a dart class should be serialized to JSON then I don't think such a spec exists. However, I am working on is a So this built_value class is intended to be a faithful reproduction of the core schema. I'm also working on a transformation framework and with that I'll create a bidirectional transformation between Json Schema and a Built Value model. So that will allow me to generate dart classes from a json schema and vice versa. It would be use a 'typical' representation of json. e.g a class like
would serialise like
In cases where you have subtypes that can be deserialized into then it'll likely need a field that identifies the type. Does that make sense? |
http://json-schema.org/example2.html contains an example json schema. I need to be able to serialize/deserialize these examples to/from instances of the Also http://json-schema.org/schema is another example. It is just json schema represented as json schema |
This issue moved to Nicer generator code: google/built_value.dart#64 |
FYI this is now happening over at |
Can use an iterator instead of one for loop and a bool to switch between keys and values.
The text was updated successfully, but these errors were encountered: