0

[{"customer_id":"12345","username":"admin","role":"1","userid":"001","status":SUCCESS"}]

How to get Json Array value in J2ME

Prasad
  • 1,188
  • 3
  • 11
  • 29
Prince Saini
  • 41
  • 1
  • 2
  • 8

1 Answers1

0

1st of all minor mistake in the string posted..it shd be

[{\"customer_id\":\"12345\",\"username\":\"admin\",\"role\":\"1\",\"userid\":\"001\",\"status\":\"SUCCESS\"}]

You can download the following files for json Parsing..Use them in your project

http://grt192.googlecode.com/svn/trunk/CannonBot/src/org/json/me/

Try the following code

    try {
        JSONArray tmparr = new JSONArray(response);
        JSONObject tmpobj = new JSONObject(tmparr.getString(0));
        System.out.println("custid " + tmpobj.get("customer_id"));
    } catch (JSONException e) {
        e.printStackTrace();
    }
  • Hi Nitin jain.. First of all thank you for reply as i submitted my code above can you please tell me about how to add json files into my project as am working in netbeans i want to save array values into client end so please suggest me right way for getting these values Thank You.. Peace .. :) – Prince Saini Feb 08 '14 at 10:59