Changes between Version 27 and Version 28 of pyson


Ignore:
Timestamp:
05/14/21 14:51:44 (4 years ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • pyson

    v27 v28  
    2222
    2323== Basic Mechanism
    24 The basic mechanism for pyson is to look at the __init__ function of the class under serialization.
    25 The arguments in the __init__ function are matched to the json fields.
    26 The arguments in the __init__ must be fully typed, and these types are used to determine how to interpret the json content.
     24The basic mechanism for pyson is to look at the {{{__init__}}} function of the class under serialization.
     25The arguments in the {{{__init__}}} function are matched to the json fields.
     26The arguments in the {{{__init__}}} must be fully typed, and these types are used to determine how to interpret the json content.
    2727
     28=== Deserialization
     29For Deserialization of a json object,  it goes like this
     30* if the target class has @JsonSubtypes,
     31 *  check which the subclasses are and what their ID is.
     32 * Determine the actual class contained in the json
     33 * "unwrap" the json, so that we have the remaining json to deserialize the actual class
     34* If it's not a JsonSubtypes, then the actual class is the requested target class
     35* now that the actual class is known,
     36 * the parameter names and param-classes from the {{{__init__}}} function of the actual class are taken
     37 * for each of the parameters, recursively deserialize the json value for that parameter, using the param-class as targetclass.
     38 * call the constructor of the target class, using the parsed json for each parameter
    2839
     40=== Serialization
     41Serialization of an object is much more straightforward.
     42* Create a json dict, with keys the arguments of the __init__ function of the object and the value the serialized value returned by the getter (also considering @JsonGetter)
     43* If the object is an instance of a class with @JsonSubtypes, add/wrap the json with class info according to the @JsonTypeInfo
    2944
    3045== Examples