1

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?

1 Answer 1

2

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.