Git Product home page Git Product logo

Comments (8)

Andersmholmgren avatar Andersmholmgren commented on April 30, 2024

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 BuiltValue classes to represent Json Schema.
I need to be able to serialize/ deserialize from regular json schema documents.

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

from built_json.dart.

davidmorgan avatar davidmorgan commented on April 30, 2024

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.

from built_json.dart.

Andersmholmgren avatar Andersmholmgren commented on April 30, 2024

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

from built_json.dart.

davidmorgan avatar davidmorgan commented on April 30, 2024

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?

from built_json.dart.

Andersmholmgren avatar Andersmholmgren commented on April 30, 2024

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 built_value representation of json schema.

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

abstract class Person implements Built<Person, PersonBuilder> {
  String get name;
  int get age;
 ...
}

would serialise like

{
  "name": "fred",
  "age": 15
}

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?

from built_json.dart.

Andersmholmgren avatar Andersmholmgren commented on April 30, 2024

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 Schema class.

Also http://json-schema.org/schema is another example. It is just json schema represented as json schema

from built_json.dart.

davidmorgan avatar davidmorgan commented on April 30, 2024

This issue moved to

Nicer generator code: google/built_value.dart#64
Nicer JSON: google/built_value.dart#65

from built_json.dart.

davidmorgan avatar davidmorgan commented on April 30, 2024

FYI this is now happening over at

google/built_value.dart#65

from built_json.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.