How to create JSON Object using String?

后端 未结 3 1799
悲哀的现实
悲哀的现实 2020-12-02 05:58

I want to create a JSON Object using String.

Example : JSON {\"test1\":\"value1\",\"test2\":{\"id\":0,\"name\":\"testName\"}}

In order to creat

3条回答
  •  伪装坚强ぢ
    2020-12-02 06:13

    In contrast to what the accepted answer proposes, the documentation says that for JSONArray() you must use put(value) no add(value).

    https://developer.android.com/reference/org/json/JSONArray.html#put(java.lang.Object)

    (Android API 19-27. Kotlin 1.2.50)

提交回复
热议问题