JsonObject Get value by key
<p>My JSON is below. I need take value by key in one loop for all objects. Current loop is wrong. I need change it. Any solutions?</p>

<pre><code> [
   {
     "key": "firstName",
     "value": "8796ccd6-56c8-441f-830b-bb1caa16d3d1"
   },
   {
    "key": "lastName",
    "value": "92e68944-e54c-4ad3-b368-cc5b35dcf9f6"
   },
   {
    "key": "user",
    "value": "0d866084-78aa-4fcf-a110-7627ce831172"
   }
]
</code></pre>

<p>My part of code:</p>

<pre><code>for (int i = 0; i &lt; jsonMainArr.length(); i++) {
    JSONObject objects = jsonMainArr.getJSONObject(i);
    Iterator key = objects.keys();
    while (key.hasNext()) {
        String k = key.next().toString();
        System.out.println("Key : " + k + ", value : " + objects.getString(k));
    }
}
</code></pre>