Search code examples
javajsonserializationcollectionsgetter-setter

Do these java classes have correct structures to map from a JSON file?


I'm parsing a JSON file into a java code from a particular URL. It looks easy. But, for some reasons the server respond with null for some key-values that I'll show below. I'm quite sure there something wrong over these structures (on the java sides). Here is the json structure.

enter image description here

And here are the codes (the getters-setters have been provided I just don't show them to make it clear)

class JSON {

    List<Result> result;

}


class Results{
    String gender;
    Name name;
    Location location
}


class Name{
    String title;
    String first;
    String last;
}

class Location {
    String city;
    String state;
    String country;
    String postcode;

}

I'm not sure where exactly I missed it. Are those classes have correct structures relative to the JSON structure?


Solution

  • It seems like you need to have results instead of result in JSON class