Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Using manual parsing you can implement it like this:</p> <pre><code> JSONArray pages = new JSONArray(jsonString); for (int i = 0; i &lt; pages.length(); ++i) { JSONObject rec = pages.getJSONObject(i); JSONObject jsonPage =rec.getJSONObject("page"); String address = jsonPage.getString("url"); String name = jsonPage.getString("name"); String status = jsonPage.getString("status"); } </code></pre> <p>in your case note that your outer elemnt data is type of JSONObject and then you have a JSONArray</p> <p>mine json file:</p> <pre><code>[{"page":{"created_at":"2011-07-04T12:01:00Z","id":1,"name":"Unknown Page","ping_at":"2011-07-04T12:06:00Z","status":"up","updated_at":"2011-07-04T12:01:00Z","url":"http://www.iana.org/domains/example/","user_id":2}},{"page":{"created_at":"2011-07-04T12:01:03Z","id":3,"name":"Down Page","ping_at":"2011-07-04T12:06:03Z","status":"up","updated_at":"2011-07-04T12:01:03Z","url":"http://www.iana.org/domains/example/","user_id":2}}] </code></pre> <p>note that mine starts from [, which means an array, but yours from { and then you have [ array inside. If you run it with a debugger, you can see exactly what´s inside your json objects.</p> <p><strong>There are also better approaches like:</strong></p> <ol> <li><a href="http://wiki.fasterxml.com/JacksonInFiveMinutes" rel="noreferrer">Jackson</a> </li> <li><a href="https://github.com/FasterXML/jackson-jr" rel="noreferrer">Jackson-JR</a> (light-weight Jackson)</li> <li><a href="https://sites.google.com/site/gson/gson-user-guide" rel="noreferrer">GSON</a></li> </ol> <p>All of them can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload