I have a Json as shown below:-
{
"componentModelData": {
"modelNumber": "ABC",
"modelName": "",
"modelDescription": "",
"modelVendor": null,
"componentName": "HELO"
},
"revisionData": {
"revisionName": "rev12",
"revisionComment": "Comment",
"modifiedBy": "2323553"
},
"configData": [{"nodes":2085,"FxPOS-SX":16.5051,"FxPOS-SY":11.0479,"FxPOS-SZ":115.3421,"FxPOS-SXY":-13.8094,"FxPOS-SYZ":36.0105
},{"nodes":2085,"FxPOS-SX":16.5051,"FxPOS-SY":11.0479,"FxPOS-SZ":115.3421,"FxPOS-SXY":-13.8094,"FxPOS-SYZ":36.0105}]
}
DataMapping.java
@Getter
@Setter
@JsonSerialize
@NoArgsConstructor
@AllArgsConstructor
public class DataMapping implements Serializable {
/**
*
*/
private static final long serialVersionUID = -2635323042843403966L;
@JsonProperty("componentModelData")
@Valid
public ComponentModelDTO componentModelDTO;
@JsonProperty("revisionData")
@Valid
public RevisionDTO revisionDTO;
@JsonProperty("configData")
private List<Object> configData;
}
I want to convert the configData list to List<HashMap<String,Double>> list
where String is the keys like 'nodes,FxPOS-SX,FxPOS-SY' and value is their respective values.
Can anyone please help me how can i achieve this?
Just replace List<Object>
with List<Map<String,Double>>
. Jackson will do the hard work for you:
@JsonProperty("configData")
private List<Map<String, Double>> configData;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.