Giter Club home page Giter Club logo

gson-record-type-adapter-factory's People

Contributors

marcono1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

npi2loup

gson-record-type-adapter-factory's Issues

Allow unknown properties by default

Proposed change

Currently RecordTypeAdapterFactory.DEFAULT disallows unknown properties in the JSON data. The logic should be reversed, unknown properties should be allowed by default and only disallowed when explicitly configured.

๐Ÿ“ข Any feedback, arguing for the current behavior or for the new proposed behavior, is highly appreciated!

Rationale

  1. Especially when working with external services, often the JSON data includes information which is not relevant for an application. It is therefore common to omit irrelevant properties from the model classes.
  2. Over time services producing JSON data might be extended to include additional properties. If applications using these services by default disallow unknown properties, such changes to the JSON data will break the applications, even if the change itself would still be backward compatible.

This change request does not cover the behavior of other configuration methods, such as allowMissingComponentValues(). Their behavior might not be a suitable default for all use cases and users should therefore explicitly make the choice to enable them.

Considerations

The documentation for the newly added method RecordTypeAdapterFactory.Builder.disallowUnknownProperties() should include a warning that disallowing unknown properties can break backward compatibility when a service (e.g. JSON REST API) is extended with new properties, see rationale 2 listed above.

The API changes will be backward incompatible, but that is probably acceptable given that this library is currently still described as experimental.

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.