java - Remove jsonobject from jsonarray -


i new android.i have simple string 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 need remove second users jsonobject:

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

so 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 use users.remove(1); method please 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 great programmers


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -