I am trying to parse the following json into Java objects. It has an outer object called BaseCategory
. BaseCategory
has a Set of Category objects. A Category has a set of SubCategory Objects.
{
"name":"base",
"categories":[
{
"name":"category1",
"subCategories": [
{
"name":"subCategory1"
},
{
"name": "subCategory2"
}
]
},
{
"name":"category2",
"subCategories": [
{
"name":"subCategory3"
},
{
"name": "subCategory4"
}
]
}
]
}
The POJO
classes are below. Stripped down to show just the relevant info. Could you please provide some help to parse this.
public class BaseCategory {
private String name;
private Set<Category> categories = new HashSet<Category>();
//setters and getters
}
public class Category {
private String name;
private Set<SubCategory> subCategories = new HashSet<SubCategory>();
//setters and getters
}
public class SubCategory {
private String name;
//setters and getters
}