Gson JsonObject versus org.json JSONObject

1,890 views
Skip to first unread message

Ryan Bateman

unread,
May 21, 2013, 2:15:05 PM5/21/13
to volley...@googlegroups.com
Hi,

I was wondering why Volley uses the org.json.* classes rather than using the Gson library equivalents?  It seems like an odd (though I'm sure, justified) choice, given how much easier Gson makes object parsing / creation.

Ryan

Ficus Kirkpatrick

unread,
May 21, 2013, 6:25:15 PM5/21/13
to Ryan Bateman, volley...@googlegroups.com
Since Volley is static, we really want to keep it as small as possible. The org.json.* stuff is included in the Android platform, so we get it for ~free/cheap. I don't want you to have to link in Gson in order to use Volley. (Gson is >2x the size of Volley, FWIW.)





Ryan

--
You received this message because you are subscribed to the Google Groups "Volley Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to volley-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ryan Bateman

unread,
May 22, 2013, 2:54:20 AM5/22/13
to volley...@googlegroups.com, Ryan Bateman
Wow. Sure, makes sense.  

Ryan Bateman

unread,
May 22, 2013, 3:16:35 AM5/22/13
to volley...@googlegroups.com, Ryan Bateman
Since I'm using Gson throughout my project anyway, I thought I'd try to create a GsonObjectRequest equivalent (pass in an object to be part of your POST/PUT body, have Gson serialise it, Volley handle it, and then have the request itself parse out the response object.)  Have I missed anything in doing so? 

Ficus Kirkpatrick

unread,
May 22, 2013, 2:30:01 PM5/22/13
to Ryan Bateman, volley...@googlegroups.com


On Wed, May 22, 2013 at 12:16 AM, Ryan Bateman <secre...@gmail.com> wrote:
Since I'm using Gson throughout my project anyway, I thought I'd try to create a GsonObjectRequest equivalent (pass in an object to be part of your POST/PUT body, have Gson serialise it, Volley handle it, and then have the request itself parse out the response object.)  Have I missed anything in doing so? 

--

Ryan Bateman

unread,
May 22, 2013, 2:32:49 PM5/22/13
to volley...@googlegroups.com, Ryan Bateman
Hi Ficus - that's pretty much what I did. (I actuallly linked to a gist of what I ended up doing in the previous post.)  Was just hoping for confirmation that I hadn't missed anything - thanks!

Ficus Kirkpatrick

unread,
May 22, 2013, 2:53:16 PM5/22/13
to Ryan Bateman, volley...@googlegroups.com
Cool. Don't forget to implement getBodyContentType()
Reply all
Reply to author
Forward
0 new messages