This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I'm trying to read the values from a JSON URL, however I don't know how I can proceed with reading the values from a List inside of an Array? I'm able to pull the JSON from a webservice, however I'm stuck trying to figure out how I could retrieve for instance the user_name from the first "Values" index of the JSON array. Below you will find my POJO, Main, and JSON code. Thank you so much for your help
public class Main {
public static void main(String[] args) {
try {
URL jsonURL = new
URL("https://jchtest.herokuapp.com/index.php?
PW=2");
ObjectMapper mapper = new ObjectMapper();
mapper.configure
(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
false);
Users[] a1 = mapper.readValue(jsonURL, Users[].class);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
}
POJO: public class Users { private List<Details> Values;
public List<Details> getValues() {
return this.Values;
}
public void setValues(List<Details> Values) {
this.Values = Values;
}
}
public class Details {
private String user_name;
private String user_password;
private int age;
private String user_email;
JSON: [ { "Values": { "user_name": "jhart", "user_password": "gooddeval1", "age": 28, "user_email": "heheh" } }, { "Values": { "user_name": "bdole", "user_password": "Passwordd", "age": 82, "user_email": "hahah" } } ]
Subreddit
Post Details
- Posted
- 8 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnprogra...