1

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?

Brian Roach
  • 76,169
  • 12
  • 136
  • 161
athor
  • 6,848
  • 2
  • 34
  • 37
  • 1
    No, what you have is an object with a field `Live` that is a `Map` where `SomeObject` has two fields; `status` and `age` – Brian Roach Feb 02 '13 at 06:18

1 Answers1

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.

Community
  • 1
  • 1