Entities to JSON

101 views
Skip to first unread message

Florian

unread,
Dec 29, 2009, 11:52:05 AM12/29/09
to Gaelyk
I'm using RPC to communicate with the backend.

So i'm wondering what would be the best thing to do in order to
convert an Entity to Json. For now i convert entities in arrays that
GWT serialize, but that's an extra step.

Also would Entity to json or PreparedQuery results as json be an
acceptable feature request for gaelyk?

Guillaume Laforge

unread,
Dec 29, 2009, 4:09:47 PM12/29/09
to gae...@googlegroups.com
Hi Florian,

Gaelyk focuses on GAE SDK enhancements, and is not trying to be a
solution for every possible need, but at least, making such needs be
easily taken care of. So I tend to promote other cool
groovy/gaelyk-friendly technologies instead.

And in this case, I think you could leverage Entity's getProperties()
method, in combination with JSON-lib's groovy-friendliness and ability
to serialize maps as JSON.

So, say you have an Entity:

def person = new Entity("person")
person.name = "Guillaume Laforge"

def jsonString = person.properties as JSONObject

Have a look at JSON-lib and the Entity JavaDoc.
And I think it'll solve your problem pretty neatly!

--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one

Richard Vowles

unread,
Dec 29, 2009, 4:20:56 PM12/29/09
to gae...@googlegroups.com
You are probably best to use one of the REST frameworks for Java (not Jersey, it does not work on GAE) and write your own converter for Entity objects, then you can pass any entity you like and it will return it.


--

Vous recevez ce message, car vous êtes abonné au groupe Google Groupes Gaelyk.
Pour envoyer un message à ce groupe, adressez un e-mail à gae...@googlegroups.com.
Pour vous désabonner de ce groupe, envoyez un e-mail à l'adresse gaelyk+un...@googlegroups.com.
Pour plus d'options, consultez la page de ce groupe : http://groups.google.com/group/gaelyk?hl=fr





--
---
Richard Vowles,
Grails, Groovy, Java
Consistency is the last refuge of the unimaginative - Oscar Wilde
ph: +64275467747, linkedin, skype:rvowles
get 2Gb shared disk space in the cloud - Dropbox, its incredibly useful! - http://tinyurl.com/cmcceh
podcast: http://www.illegalargument.com

Florian

unread,
Dec 30, 2009, 4:28:13 AM12/30/09
to Gaelyk
Ok i see, thanks :)

On Dec 29, 10:09 pm, Guillaume Laforge <glafo...@gmail.com> wrote:
> Hi Florian,
>

Guillaume Laforge

unread,
Dec 30, 2009, 4:41:23 AM12/30/09
to gae...@googlegroups.com
I hope the solution is simple enough :-)

That's what I like about the facilities provided by Groovy, and
Groovy-friendly libraries. We don't even need a special support in
Gaelyk, it's working out of the box with an external library!

> --
>
> Vous recevez ce message, car vous êtes abonné au groupe Google Groupes Gaelyk.
> Pour envoyer un message à ce groupe, adressez un e-mail à gae...@googlegroups.com.
> Pour vous désabonner de ce groupe, envoyez un e-mail à l'adresse gaelyk+un...@googlegroups.com.
> Pour plus d'options, consultez la page de ce groupe : http://groups.google.com/group/gaelyk?hl=fr
>
>
>

--

Reply all
Reply to author
Forward
0 new messages