vendredi 31 juillet 2015

how to parse this JSON file using jackson?

I have this JSON file

{
  "personal": {
    "name": "John Doe",
    "age": "28",
    "gender": "male",
  }
}

This is the POJO I want to parse it to

public class customerInfo{
   private String infoType;
   private Map<String, String>;
}

The reason I want to use this POJO because the JSON file could also be

{
  "address": {
    "street": "123 main st",
    "state": "md",
    "zipcode": "21228"
  }
}

This is what I tried but it didn't work

customerInfo customer = mapper.readValue(new File("jsonTestFile.json"), customerInfo.class);

Any help please? Thank you!

Aucun commentaire:

Enregistrer un commentaire