1

In iOS if I have arrays and maps nested, I can call NSJSONSerialization.dataWithJSONObject method, and it will render it to a JSON string. For map, or NSDictionary I can use the setValueForKey method, for array, or NSArray I can use add method to populate with data. How is it possible in Android?

Is this approach works in Android? Does appropriate methods exist in Android?

  • NSJSONSerialization.dataWithJSONObject
  • setValueForKey
  • add
János
  • 32,867
  • 38
  • 193
  • 353

1 Answers1

3
  • NSJSONSerialization.dataWithJSONObject

https://github.com/google/gson

GSON is a very well supported and used JSON serialisation and deserialisation library. It is very easy to use.

  • setValueForKey

https://developer.android.com/reference/org/json/JSONObject.html

You can also manually manipulate JSON objects using the classes available in the platform itself.

  • add

https://developer.android.com/reference/org/json/JSONArray.html

Everything you can do in iOS you can do in Android :) Just maybe slightly differently

Ken Wolf
  • 23,133
  • 6
  • 63
  • 84