1

I am new with android.I have simple string look like this:

String json={"time":"12.00", "data":"25/01/2014","users":
[

{"id":1231,"title":"hello","url":"world"},
{"id":7656,"title":"hello","url":"world"},
{"id":3356,"title":"hello","url":"world"}

],"is_valid":false}

And now I need to remove second users JSONObject:

{"id":7656,"title":"hello","url":"world"}

So I try following:

JSONObject json=new JSONObject(json);
JSONArray users=json.getJSONArray("users");
users.remove(1);
json.put("users",users);
String new_json=json.toString();

But unfortunately application forced close every time when I use users.remove(1); method please someone help me.

I need following string after removing object:

String new_json=
tring json={"time":"12.00", "data":"25/01/2014","users":
[

{"id":1231,"title":"hello","url":"world"},
{"id":3356,"title":"hello","url":"world"}

],"is_valid":false}

Thanks to all great programmers

Ashish Sahu
  • 1,538
  • 17
  • 22

0 Answers0