twotoasters / hoot

A powerful, flexible, lightweight Android library for dealing with RESTful endpoints.
Apache License 2.0
26 stars 10 forks source link

Stock deserializer classes. #4

Open twaddington opened 12 years ago

twaddington commented 12 years ago

So I was thinking a bit about deserializers and was wondering what you thought about including some stock deserializers. Something like this:

HootDeserializer (abstract)
HootStreamDeserializer (abstract?)
HootStringDeserializer
HootJsonObjectDeserializer (deserializes to a JSONObject)
HootJsonArrayDeserializer (deserializes to a JSONArray)

The "default" deserializer could simply be an instance of HootStringDeserializer. That way you won't have to call setDeserializer() if you just want the response content back as a string. Otherwise, you can call setDeserializer() with one of the stock classes to override the default: setDeserializer(new HootJsonObjectDeserializer()) to just get back a deserialized JSONObject. That will probably be sufficient for most people who don't have more complicated deserializations to perform on the background thread. For others, they can feel free to write custom deserializers for things like GSON, Jackson or custom objects.

What do you think?

bjdupuis commented 12 years ago

I actually dig it a lot. Nice thinking!

On Thu, Oct 4, 2012 at 1:57 PM, Tristan Waddington <notifications@github.com

wrote:

So I was thinking a bit about deserializers and was wondering what you thought about including some stock deserializers. Something like this:

HootDeserializer (abstract) HootStreamDeserializer (abstract?) HootStringDeserializer HootJsonObjectDeserializer (deserializes to a JSONObject) HootJsonArrayDeserializer (deserializes to a JSONArray)

The "default" deserializer could simply be an instance of HootStringDeserializer. That way you won't have to call setDeserializer()if you just want the response content back as a string. Otherwise, you can call setDeserializer() with one of the stock classes to override the default: setDeserializer(new HootJsonObjectDeserializer()) to just get back a deserialized JSONObject. That will probably be sufficient for most people who don't have more complicated deserializations to perform on the background thread. For others, they can feel free to write custom deserializers for things like GSON, Jackson or custom objects.

What do you think?

— Reply to this email directly or view it on GitHubhttps://github.com/twotoasters/hoot/issues/4.

Brian Dupuis Two Toasters | Lead Android Developer brian@twotoasters.com

twaddington commented 12 years ago

Sweet! I'm happy to take a stab at this if you like. Although, you seem to be rocking the library right now. Don't want to step on your toes.

bjdupuis commented 12 years ago

I need to return to spec work so if you're bored and driven, feel free. If you don't decide to tackle it, let me know so I can throw it on my todos.

Thanks.

On Thu, Oct 4, 2012 at 2:06 PM, Tristan Waddington <notifications@github.com

wrote:

Sweet! I'm happy to take a stab at this if you like. Although, you seem to be rocking the library right now. Don't want to step on your toes.

— Reply to this email directly or view it on GitHubhttps://github.com/twotoasters/hoot/issues/4#issuecomment-9151097.

Brian Dupuis Two Toasters | Lead Android Developer brian@twotoasters.com

twaddington commented 12 years ago

Roger that.