alalonde alalonde - 1 month ago 6
Android Question

Why isn't there a remove(int position) method in Android's JSONArray?

I started building an Android app that uses a flat file for storage. The app doesn't store more than six records, and I'm familiar with JSON, so I just write out a

to the file.

I just discovered today, though, that the Android JSON API doesn't include a
option. Huh? Do I have to dump the array into another collection, remove it, then rebuild the
? What's the point?


The point is that JSONArray and JSONObject are meant to (de)serialize data to JSON, not manipulate data. A remove() method may seem to make sense, but where's the limit? Would you expect to be able to access attributes on serialized objects? Access or update nested data structures?

The idea is, indeed, that you manipulate data structures "natively".