title: how to get specific value from json file in java
body: <p>I have a json file like this:</p>
  
  <pre><code>{
      "list": [
          {
              "ID" : "1",
              "value" : "value is one"
          }
          {
              "ID" : "2",
              "value" : "value is two"
          }
          {
              "ID" : "3",
              "value" : "value is three"
          }
          {
              "ID" : "4",
              "value" : "value is four"
          }
      ]
  }
  </code></pre>
  
  <p>what I want to do is read the josn file and returns the message based on the ID i specify. So for example</p>
  
  <pre><code>if (this.list.containsKey("1"))
      {
          return this.list.get(messageTitle);
      }
  </code></pre>
  
  <p>That's what I tried but it returns all the values and ID.</p>
  
  <pre><code>JSONParser parser = new JSONParser();
  try {
      Object obj = parser.parse(new FileReader("jsonFile.json"));
      JSONObject jsonObject = (JSONObject) obj;
      // loop array
      JSONArray msg = (JSONArray) jsonObject.get("list");
      Iterator&lt;String&gt; iterator = msg.iterator();
      while (iterator.hasNext()) {
          System.out.println(iterator.next());
      }
  }
  </code></pre>