I'm trying to include Spring for Android as a client to a Spring server in a mobile app project. After looking at the documentation (https://docs.spring.io/spring-android/docs/1.0.1.RELEASE/reference/html/rest-template.html) I would like to use
the method getForObject() to directly create the objects I will use in the code. All the exemples I find on internet only show what to do with more primitive type for the value of each key (String, long, int). The JSON object sent back from the server looks like this :
{
"id": "MSP-SS-043208",
"nom": "Inondation-Débit-Niveau",
"source": "Ministère de la Sécurité publique du Québec",
"territoire": "Rivière des Mille Îles(043208)",
"certitude": "Observé",
"severite": "Mineure",
"dateDeMiseAJour": "lundi 04 juin 2018",
"urgence": "Future",
"description": "Seuil de surveillance atteint",
"count": 1,
"geometry": {
"type": "Point",
"coordinates": [-73.6387202781213, 45.6928705203507]
},
"type": "Suivi des cours d'eau"
}
My problem is I have no idea what to do with the geometry key because it is not a primitive object ! How can I make Spring recognize that there is a JSON object as the attribute of a certain key ? And what about the array of double (coordinates)?
This is the class I am trying to use:
public class Alert {
private String id;
private String nom;
private String source;
private String territoire;
private String certitude;
private String severite;
private String dateDeMiseAJour;
private String urgence;
private String description;
private int count;
private ????? geometry;
private String type;
... gettters and setters ...
}
My question comes down to : How must I declare the geometry attribute to make sure the objects are created correctly ?