Android : Best way to remove JSON object from JSON object

on Wednesday, October 29, 2014


Assuming that I have a JSONObject


{ "poll_answers":{ "213":{ "poll_answer_text":"Black", "poll_answer_id":"213" }, "214":{ "poll_answer_text":"White", "poll_answer_id":"214" }, "218":{ "poll_answer_text":"Colorful", "poll_answer_id":"218" } } }


what is the most relevant/best way to remove** a JSONObject with key "214" (for example) since the android remove method returns the value previously mapped by the key but not the given object excluding the object I want to remove. So the solution should look like:


{ "poll_answers":{ "213":{ "poll_answer_text":"Black", "poll_answer_id":"213" }, "218":{ "poll_answer_text":"Colorful", "poll_answer_id":"218" } } }


0 comments:

Post a Comment