Hello,
This is the JSON file I want to convert into Java object
{
"personal": {
"name": "John Doe",
"age": "28",
"gender": "male",
}
"address": {
"street": "123 main st",
"state": "md",
"zipcode": "21228"
}
}
The java object im creating is
public class customerInfo{
private String infoType;
private Map<String, String>;
}
So basically what I want is a List<customerInfo> where
element 1:
infoType = personal
Map = <name, John Doe>, and so on
element 2:
infoType = address
Map = <street, 123 main st>, and so on
This is what I've been trying so far but couldn't get it to work
customerInfo customer = mapper.readValue(new File("jsonTestFile.json"), customerInfo.class);
I only put the first portion of the test file to test that line of code.
So the jsonTestFile.json content is
{
"personal": {
"name": "John Doe",
"age": "28",
"gender": "male",
}
}
so how do I deserializing the json object in both scenarios?
Thank you very much