<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>To extract data from jSON array</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=34225287" />
  <subtitle>To extract data from jSON array</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=34225287</id>
  <updated>2026-06-07T05:42:47Z</updated>
  <dc:date>2026-06-07T05:42:47Z</dc:date>
  <entry>
    <title>RE: To extract data from jSON array</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=34228597" />
    <author>
      <name>Meera Prince</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=34228597</id>
    <updated>2014-02-12T08:38:30Z</updated>
    <published>2014-02-12T08:38:30Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi &lt;br&gt;You are getting response is JSON array so frst create JSON array object not JSON Object&lt;br&gt;&lt;br&gt;Try following code&lt;br&gt;&lt;pre&gt;&lt;code&gt;String json = HttpUtil.decodePath(url);
	JSONArray jsonArray = JSONFactoryUtil.createJSONArray(json);
	for (int index = 0;index &amp;amp;lt; jsonArray.length(); index++) {
		JSONObject jsonObject = jsonArray.getJSONObject(index);
		System.out.println("width"+jsonObject.getString("width"));
		System.out.println("width"+jsonObject.getString("height"));
		JSONObject activeNodeJsonObject = jsonObject.getJSONObject("activeNode");
		System.out.println("Name"+activeNodeJsonObject.getString("name"));
		System.out.println("X"+activeNodeJsonObject.getString("x"));
		System.out.println("Y"+activeNodeJsonObject.getString("y"));
		
	}&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;Meera Price&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Meera Prince</dc:creator>
    <dc:date>2014-02-12T08:38:30Z</dc:date>
  </entry>
  <entry>
    <title>To extract data from jSON array</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=34225286" />
    <author>
      <name>Kannan G krishnan</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=34225286</id>
    <updated>2014-02-12T07:12:15Z</updated>
    <published>2014-02-12T07:12:15Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi community,&lt;br&gt; I have a requirement in my project that i want to retrieve data from a JSON url like&lt;br&gt;&lt;pre&gt;&lt;code&gt;localhost:8080/gwt-console-server/rs/process/instance/258/activeNodeInfo&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;I am trying to get the data from the jBPM workflow part. When i load this url i got the window with some display like,&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;[{"width":932,"height":541,"activeNode":{"name":"id\u003d13","x":662,"y":123,"width":118,"height":40}}]&lt;/code&gt;&lt;/pre&gt; &lt;br&gt;&lt;br&gt;I believe the values are there in the array. I want to store each of the values in different variables. &lt;br&gt;&lt;br&gt;i used the code like, &lt;br&gt;&lt;pre&gt;&lt;code&gt;try {
        	  List&amp;lt;string&amp;gt; result = new ArrayList&amp;lt;string&amp;gt;();
              String url = "http://localhost:8080/gwt-console-server/rs/process/instance/258/activeNodeInfo";
              String json = HttpUtil.decodePath(url);
              
                      JSONObject resultJsonObject = new JSONObject(json);
                      JSONArray jsonArray = resultJsonObject.getJSONArray("results");
                      System.out.println("jsonArray--&amp;amp;gt;"+jsonArray);
                      String name = null;
                      for (int index = 0, total = jsonArray.length(); index &amp;amp;lt; total; index++) {
                              final JSONObject jsonObject = jsonArray.getJSONObject(index);
                             
                              name = jsonObject.getString("name");
                              result.add(name);
                      }
                      System.out.println("result--&amp;amp;gt;"+result);
              } catch (JSONException e) {
                      throw new RuntimeException(e+"here");
              }&amp;lt;/string&amp;gt;&amp;lt;/string&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;But this is not working. How can i do this in liferay??&lt;br&gt;&lt;br&gt;Regards&lt;br&gt;Kannan G.krishnan&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Kannan G krishnan</dc:creator>
    <dc:date>2014-02-12T07:12:15Z</dc:date>
  </entry>
</feed>
