New filters on the Home Feed, take a look!
view details

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.

0
Java ; JSON ; Jackson ; Retrieving the value from a List inside an Array from JSON
Post Body

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" } } ]

Author
Account Strength
80%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
398
Link Karma
165
Comment Karma
233
Profile updated: 3 days ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
8 years ago