I have a JSON layout where the outer structure field is an array which everything else is par of it.
{
"attribute1":[
{
"@attribute2":"something",
"attribute3":"something too",
"attribute4":["something else"],
"attribute5":{
"what":"dont know",
"carrier":"mailto:something@gmail.com"
}
}
]
}
I have the following POJO class:
public class Dataset {
private List<object> attribute1;
private String attribute2;
private String[] attribute3;
private Map<String, String> attribute4;
}
I have the accessors and getters methods defined too.
I instantiate the class ObjectMapper
to use the readValue
method to serialize the above file using the POJO class.
I have two issues:
1. How I define attribute1
so it contains everything that is embedded as array list?
2. When I try to parse the @attribute2
it errors out. I have to remove the @
in order to pass this error. The file contains lot of attributes with @
sign.
How do I handle that from the source file without modifying it?
> mapType = new TypeReference
>() {}; List jsonToPersonList = objectMapper.readValue("location\data.json", mapType);
Is this a start.... I did modified but I getting an error cannot deserialize instance of ArrayList out of start_object token