Changes between Version 28 and Version 29 of pyson


Ignore:
Timestamp:
05/18/21 08:37:28 (4 years ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • pyson

    v28 v29  
    4242* 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)
    4343* If the object is an instance of a class with @JsonSubtypes, add/wrap the json with class info according to the @JsonTypeInfo
     44
     45== Annotations
     46
     47The following annotations are available
     48
     49=== {{{@JsonGetter}}}
     50Added to a function definition in a class. Takes "value" as argument, containing the name of a json field (which is also used as argument in the constructor).
     51
     52Indicates that that function is to be used to get the value of the given json field.
     53
     54=== {{{@JsonSubTypes}}}
     55Added to a class definition. Takes a list of strings as argument. Each string is the full class path to another class.
     56
     57Indicates that that other class is a sub-class of the annotated class. The other class can be used for deserialization as well.
     58
     59If this is used, the @JsonTypeInfo must also be provided.
     60
     61=== {{{@JsonTypeInfo}}}
     62Added to a class definition. Contains "Id" and "As" values.
     63
     64Indicates that the class name/id should be included in the json code.  This is especially useful in combination with {{{@JsonSubTypes.}}}
     65
     66The "Id" value can have the value NONE, NAME, CLASS. We recommend to use NAME,
     67||NONE|| Do not include class id at all. Do not use this with @JsonTypeInfo. Only included because it was availale in Jackson||
     68||NAME||Use the name of the class to refer to the class. All classes referred must have different name (not two the same names with different classpath).||
     69||CLASS||Use the full.class.path to refer to the class. ||
     70
     71We recommend NAME, because it is shorter and gives more readable json, and gives you flexibility to move around the actual classes if needed without breaking compabibility with existing json files||
     72
     73
     74Indicates how to include the class name is included in/extracted from the json.
     75
     76====
     77
     78=== Inheritance of annotations
     79The usual inheritance mechanism of python applies also to the annotatinos.
     80
     81
    4482
    4583== Examples