Trouble with converting Json in Java
<p>I'm trying to read in a somewhat complex json string and I'm having problems with nested items and how to retrieve them. </p>

<p>My java code looks like the following</p>

<pre><code>String longJson = "{'Patient': {'Name': {'Given': 'FirstName','Family': 'LastName'},'Gender': 'Female','DOB': '1980-07-04T00:00:00.0000000','AgeInYears': 36,'MartialStatus': 'Single', 'Race': 'Race','Ethnicity': 'Ethnicity','Class': 'Inpatient','Address': {'StreetAddress': 'StreetAddress','City': 'City','State': 'State','ZipCode': 'ZipCode', 'Country': 'Country'}}}";

    Gson gson = new Gson();

    PrescriptionReq sample = null;
    sample = gson.fromJson(longJson, PrescriptionReq.class);


    String firstName = sample.getPatient().getName().getGiven();
    //String firstName = sample.patient.name.getGiven();
    System.out.println("Testing: "+ firstName);
</code></pre>

<p>When I run either approach I get a null point exception</p>

<p>Here is the Json in a more readable view</p>

<pre><code>        {
        "Patient": {
            "Name": {
                "Given": "FirstName",
                "Family": "LastName"
            },
            "Gender": "Female",
            "DOB": "1980-07-04T00:00:00.0000000",
            "AgeInYears": 36,
            "MartialStatus": "Single",
            "Race": "Race",
            "Ethnicity": "Ethnicity",
            "Class": "Inpatient",
            "Address": {
                "StreetAddress": "StreetAddress",
                "City": "City",
                "State": "State",
                "ZipCode": "ZipCode",
                "Country": "Country"
            }
        }
    }
</code></pre>

<p>Here are my classes: </p>

<pre><code>public class PrescriptionReq {
private Patient patient;

public Patient getPatient(){
    return patient;
}

public class Patient {
    Name name;
    Address address;

    public Name getName(){
        return name;
    }
    //Other variables
   }

public class Name {
    private String Given;
    private String Family;

    public String getGiven() {
        return Given;
    }

    public String getFamily() {
        return Family;
    }

   }
}
</code></pre>

<p>I'm not sure if I am storing the json wrong or retrieving it wrong.  Any help is much appreciated!</p>