| 44 | |
| 45 | == Annotations |
| 46 | |
| 47 | The following annotations are available |
| 48 | |
| 49 | === {{{@JsonGetter}}} |
| 50 | Added 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 | |
| 52 | Indicates that that function is to be used to get the value of the given json field. |
| 53 | |
| 54 | === {{{@JsonSubTypes}}} |
| 55 | Added to a class definition. Takes a list of strings as argument. Each string is the full class path to another class. |
| 56 | |
| 57 | Indicates that that other class is a sub-class of the annotated class. The other class can be used for deserialization as well. |
| 58 | |
| 59 | If this is used, the @JsonTypeInfo must also be provided. |
| 60 | |
| 61 | === {{{@JsonTypeInfo}}} |
| 62 | Added to a class definition. Contains "Id" and "As" values. |
| 63 | |
| 64 | Indicates that the class name/id should be included in the json code. This is especially useful in combination with {{{@JsonSubTypes.}}} |
| 65 | |
| 66 | The "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 | |
| 71 | We 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 | |
| 74 | Indicates how to include the class name is included in/extracted from the json. |
| 75 | |
| 76 | ==== |
| 77 | |
| 78 | === Inheritance of annotations |
| 79 | The usual inheritance mechanism of python applies also to the annotatinos. |
| 80 | |
| 81 | |