title: How to get JSON value using Java
body: <p>I want to get a value from JSON using Java.</p>
  
  <p>The value I want to get is <code>city</code> and <code>country</code>.  </p>
  
  <p>I use json-simple library, Here is the JSON:</p>
  
  <pre><code>{
    "company" : {
      "name" : {
        "leader" : "leader_name" 
      },
      "location" : {
        "city" : "city_name",
        "country" : "country_name"
      }
    }
  }
  </code></pre>
  
  <p>This is the Code:</p>
  
  <pre><code>package readjson;
  
  import java.io.FileReader;
  import org.json.simple.JSONObject;
  import org.json.simple.parser.JSONParser;
  
  public class ReadJson {
  
  public static void main(String[] args) { 
      JSONParser jp = new JSONParser();
      try {
  
          Object object = jp.parse(new FileReader("/home/azuharu/output.json"));
          JSONObject jso = (JSONObject) object;
  
          String city = (String) jso.get("city");
          String country = (String) jso.get("country");
  
          System.out.println("city: "+city);
          System.out.println("country: "+country);
  
      } catch (Exception e) {
          e.printStackTrace();
      }    
    }
  }
  </code></pre>
  
  <p>city and country is null and I expect it to be.  Why isn't the correct value being printed?</p>