我必须准备模型以将响应发送到模型。
这是收到的示例 JSON 格式:
{
\\ rest of the model
"Model": {
"name": "name_01",
"description": "name_01",
"features": {
"name": "feature 01",
"description": "feature 01"
}
}
\\ Rest of the model
}
要发送到 fronEnd 的响应:
{
\\ rest of the model
"model_name":"name_01",
"feature_name":"feature_01"
}
\\ rest of the model
这是我到目前为止实现的:
代码:
@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");
}
有没有更好的办法?