Basic mode - JSON source
Import Trevas Jackson module
<dependency>
<groupId>fr.insee.trevas</groupId>
<artifactId>vtl-jackson</artifactId>
<version>1.7.0</version>
</dependency>
SchEma
The JSON representation of a Dataset
is defined as follows:
{
"dataStructure": [
{ "name": "id", "type": "STRING", "role": "IDENTIFIER" },
{ "name": "x", "type": "INTEGER", "role": "MEASURE" },
{ "name": "y", "type": "FLOAT", "role": "MEASURE" }
],
"dataPoints": [
["0001", 10, 50.5],
["0002", 20, -8],
["0003", 1000, 0],
["0004", 1, 4.5]
]
}
Usage of the vtl-jackson
module
Global declaration
The module can be globally declared at the scope of the client project.
public ObjectMapper objectMapper() {
return new ObjectMapper()
.registerModule(new TrevasModule());
}
Deserialization example
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.readValue(json, Dataset.class);