Git Product home page Git Product logo

built_json.dart's Introduction

Built JSON for Dart

Build Status

Introduction

Built JSON provides serialization for the [Libraries for Object Oriented Dart] (https://github.com/google/built_value.dart/blob/master/libraries_for_object_oriented_dart.md#libraries-for-object-oriented-dart).

This allows a complete serializable object oriented data model to be based on Enum Classes, [Built Collections] (https://github.com/google/built_collection.dart#built-collections-for-dart) and [Built Values] (https://github.com/google/built_value.dart#built-values-for-dart).

Built JSON for Java, a separate project, will provide compatible serialization for Java, mapping Enum Classes to standard Java enums, Built Collections to [Immutable Collections] (https://github.com/google/guava/wiki/ImmutableCollectionsExplained) and Built Values to [AutoValues] (https://github.com/google/auto/tree/master/value#autovalue).

Example Code

[Simple examples] (https://github.com/google/built_json.dart/tree/master/example); for a more realistic project see the chat example for an end to end use of built_json on server and client.

Motivation

There are many ways to serialize data. Why do we need another?

Built JSON is about serialization of object oriented data. There are many ways to do this, too. Built JSON is different to other libraries for a number of reasons:

Built JSON fully supports object oriented design: any object model that you can design can be serialized, including full use of generics and interfaces. Some other libraries require concrete types or do not fully support generics.

Built JSON allows different object oriented models over the same data. For example, in a client server application, it's likely that the client and server want different functionality from their data model. So, they are allowed to have different classes that map to the same data. Most other libraries enforce a 1:1 mapping between classes and types on the wire.

Built JSON requires well behaved types. They must be immutable, can use interface but not concrete inheritance, must have predictable nullability, hashCode, equals and toString. In fact, they must be Enum Classes, Built Collections or Built Values. Some other libraries allow badly behaved types to be serialized.

Built JSON supports changes to the data model. Optional fields can be added or removed, and fields can be switched from optional to required, allowing your data model to evolve without breaking compatbility. Some other libraries break compatability on any change to any serializable class.

Built JSON is modular. Each endpoint can choose which classes to know about; for example, you can have multiple clients that each know about only a subset of the classes the server knows. Most other libraries are monolithic, requiring all endpoints to know all types.

Built JSON is multi language. Support will be come first for Dart, Java and Java/GWT. Many other libraries support a single language only.

Built JSON has first class support for validation via Built Values. An important part of a powerful data model is ensuring it's valid, so classes can make guarantees about what they can do. Other libraries also support validation but usually in a less prominent way.

And, finally, Built JSON is pluggable. Arbitrary extensions can be added to give custom JSON serialization for your own types. This could be used to interoperate with other tools or to add hand coded high performance serializers for specific classes. Some other libraries are not so extensible.

Features and bugs

Please file feature requests and bugs at the issue tracker.

built_json.dart's People

Contributors

blackhc avatar davidmorgan avatar

Watchers

 avatar

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.