Hi
I am trying to save a list of points in a structure like this:
{
"id": 797,
"name": "Rudbøl Sø",
"points": [
{
"lon": "8.7889129103",
"lat": "54.9007764066"
},
{
"lon": "8.8068412967",
"lat": "54.9086568131"
},
{
"lon": "8.7912673708",
"lat": "54.9041377725"
},
{
"lon": "8.7601299969",
"lat": "54.8950937050"
}
]
},
In my java code the list of points are List<Point>
ie. a simple Java list.
I have tried to save it like this (simplified):
protected boolean updateField(JsonObject node, final String field, final List<?> value) {
JsonArray vNew = JsonArray.from(value);
node.put(field, vNew);
return true;
}
But that appears to not be possible. It seems that my code hangs around the node.put(...)
. Do I have to manually create a new JsonArray, create an JsonObject for each POJO, and use ...put()
as String/Double for each of the attributes??