Best way to deserialize dynamic nested json

Home / Uncategorized / Best way to deserialize dynamic nested json

Question:
I have a nested json which looks like
{
profiles : {
"mike": "123",
"jack": "456"
}
}

The profile json can be dynamic ie I dont know how many profiles/name will be there in it. I just get the request. It could be 2 or 3 or X. In java I tried

Company.java
public class company {
@JsonProperty("profiles")
Profiles profile;
}

Profiles.java
public class profiles{
JsonObject info;
}

This is wrong. What is the right way to get that nested json?


Answer:
public class company {
@JsonProperty("profiles")
Map profiles;
}
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *