2

I have the following JSON:

{
    "Live": {
        "Saerro (AU)": {
            "status": "low",
            "age": "00:01:17"
        },
        "Connery (US West)": {
            "status": "medium",
            "age": "00:02:26"
        }
    }
}

So the Map Live has Map<String,Map<String,String>> as its values. I need to deserialize Live into a list of objects,e.g.

public class Status implements Serializable {
    @JsonProperty
    public String name;
    @JsonProperty
    public String status;
    @JsonProperty
    public String age;
}

Is there an annotation or something I can use, so that the Map Key,and values get deserialized into one object?

1
  • 1
    No, what you have is an object with a field Live that is a Map<String,SomeObject> where SomeObject has two fields; status and age Commented Feb 2, 2013 at 6:18

1 Answer 1

1

You would need to write a custom deserializer to handle this. This gives a decent overview, and there are a number of other questions on stackoverflow that cover this, for example here.

Alternatively, you could let Jackson deserialize in to a Map<String, Map<String, String>> and then post-process it in to whatever form you wish.

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.