tags:

views:

21

answers:

1

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 JSONArray to the file.

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

A: 

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".

Ivo van der Wijk