org.json.JSONObject in Gson

755 views
Skip to first unread message

Sea

unread,
Apr 4, 2013, 11:43:32 AM4/4/13
to googl...@googlegroups.com
Hello,

I would like to use Gson in an android application. A part of the application use org.json.JSONObject wich is provided with Android.

Is there anyway to use org.json.JSONObject with Gson ?
I try to use it but between the 2 frameworks, today, I use JSON as String which is not really good.
What I mean is for instance when the appilcation receives JSON, the String is parsed by org.json.JSONObject then it's serialized in String before GSON component that parse again the string.

Any idea ?

Stéphane

Inderjeet Singh

unread,
Apr 4, 2013, 12:46:17 PM4/4/13
to googl...@googlegroups.com
You can write a utility that converts the DOM objects between the two: JSONObject into Gson JsonObject, JSONArray to JsonArray.

Using String is actually not that bad an idea, especially in an Android phone since they are quite powerful devices these days. Are you running into any specific issues? Is your JSON huge?

Inder
Reply all
Reply to author
Forward
0 new messages