JSON Reply

36 views
Skip to first unread message

David Karam

unread,
Jul 21, 2011, 12:22:36 PM7/21/11
to Open.Sen.se Forum
Hello all,

I am using GSON to deserialize the json output from sen.se into a Java
Object. I am facing a small problem.

I normally get the following reply:

[
{
"publish_id": "51F407EAE91F7",
"value": 117,
"timetag": "2011-07-21T16:02:50.949493+00:00",
"feed_id": 3318,
"id": 23174927,
"unit": "°C"
}
]

which is not compatible with what GSON is expecting, as GSON needs an
identifier for the array and all objects in question, so something
like this:

{
"senseReply": {
"feedList": [
"feedInfo":
{
"publish_id": "51F407EAE91F7",
"value": 117,
"timetag": "2011-07-21T16:02:50.949493+00:00",
"feed_id": 3318,
"id": 23174927,
"unit": "°C"
}
]
}
}

would be needed to be compatible with Java Object-json mappers.

I don't know if I am doing something wrong, but my feeling is that the
API response format is not too compatible with json-object mappings
tools like GSON or so. It's hard to use (for the purposes of my
application) the platform without the ability to automate the
serialization and deserialization of the feeds (i.e. I cannot do it by
hand with the low-level parsers)


If anyone has any ideas, it would be great to hear your opinion on the
matter.


Best regards,
David

Nicolas Mechin

unread,
Jul 21, 2011, 4:42:05 PM7/21/11
to sens...@googlegroups.com
Hi David,

I'm not too familiar with GSON, but it seems that you could find an answer to your question here : http://rishabhsays.wordpress.com/2011/02/24/parsing-list-of-json-objects-with-gson/

Cheers,

Nicolas
Reply all
Reply to author
Forward
0 new messages