Code Monkey home page Code Monkey logo

typetraversalconverter's Introduction

TypeTraversalConverter

This is a custom type converter for Json.net meant to handle custom logic for class hierarchy deserialization.

Essentially the converter is meant to deserialize an object into the the deepest child class known by the calling code.

While generally this is not needed, in a use case where server code is updated with new child types and client code does not receive the update, the goal is to deserialize to the closest parent known by the client.

For example, the server and client both know about "Food", "Fruit", and "Carrot" objects. Then, the server adds a "Pepper" object to its domain, and the client does not receive the update. If the client received a "Pepper" object from the server, rather than breaking serialization, it should receive a "Vegetable" object.

This is done through enum to type mapping and a ':' separated hierarchy string.

There is an added benefit of averting the risk point in serialization described here and here since it does not rely on the automatic $type handling.

typetraversalconverter's People

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.