I have to prepare the model for the response to be sent to model.
This is the sample JSON format that is received:
{
\\ rest of the model
"Model": {
"name": "name_01",
"description": "name_01",
"features": {
"name": "feature 01",
"description": "feature 01"
}
}
\\ Rest of the model
}
Response to be sent to the fronEnd :
{
\\ rest of the model
"model_name":"name_01",
"feature_name":"feature_01"
}
\\ rest of the model
This is what I implemented so far:
Code:
@SuppressWarnings("unchecked")
@JsonProperty("model")
private void unpackNestedModel(Map<String,Object> model) {
this.model_name = (String) model.get("name");
Map<String, Object> model2 = (Map<String, Object>) model.get("features");
this.feature_name = (String) model2.get("name");
}
Is there a better way?
You can parse the result by
JSONObject, but suggest to operate json result through POJO Object.