I am trying to parse the JSON data which is present in datas.json.I need to parse the Exclusion datas using Beans/POJO classes.The JSON data is as follows:
"ExclusionList" : {
"serviceLevel" : ["sl1","sl2","sl3"],
"item" : ["ABC","XYZ"] } }
I've created POJO classes for the ExclusionList but unable to get and print in the console of ECLIPSE IDE.Mypojo class:
List<String> serviceLevel;
List<String> item;
//with gettter and setters.
My main class is as follows:
public static void main(String[] args)
throws JsonParseException, JsonMappingException, IOException, ParseException, JSONException {
File jsonFile = new File("C:\\Users\\sameepra\\Videos\\datas.json");
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
ExclusionList exclusionlist=mapper.readValue(jsonFile,ExclusionList.class);
List<String> excllist=exclusionlist.getServiceLevel();
for (int i = 0; i < excllist.size(); i++) {
System.out.println(excllist.get(i));
}
}
Getting error as Exception in thread "main" java.lang.NullPointerException
List<String> excllist??