Read the json object and store into the bean by creating the new getter n setter. I want to read the bold value from below json object received as string.
[{"country":"**India**","provinces":[{**"province":"India","confirmed":265928,"recovered":129095,"deaths":7473,"active":129360**}],"latitude":20.593684,"longitude":78.96288,"date":"2020-06-08"}]
Bean:
@JsonIgnoreProperties(ignoreUnknown = true)
public class CoronaBean {
private String country; } and other needs to be created
ObjectMapper mapper = new ObjectMapper();
try {
CoronaBean[] coronaBean = mapper.readValue(json, CoronaBean[].class);
for(CoronaBean c: coronaBean ){
System.out.println(c.getCountry());
}
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I am successfully able to read the country but I want to read other values which are in bold above