Creating custom JSON using JAXRS

138 views
Skip to first unread message

mikes

unread,
Nov 21, 2011, 1:41:17 PM11/21/11
to grails-jaxrs-discuss
Can anyone give me pointers on how to create custom JSON(custom
provider) using JAXRS in Grails?

thanks

Martin Krasser

unread,
Nov 22, 2011, 5:33:58 AM11/22/11
to grails-jax...@googlegroups.com
Hi mikes,

here's an incomplete list of options:

- Resource methods can return instances of grails.converters.JSON. The
grails-jaxrs plugin has a provider for converting between JSON
representations and grails.converters.JSON objects (see also
http://code.google.com/p/grails-jaxrs/wiki/AdvancedFeatures#Entity_providers)
* JSON instances can be created by calling 'as JSON' on a Grails
domain objects
* JSON instances can also be created with grails.web.JSONBuilder:
With JSONBuilder you can create any custom JSON repsonse you like

- If you want to write a custom provider please take a look at
http://code.google.com/p/grails-jaxrs/wiki/AdvancedFeatures#Custom_providers

* With a custom provider you can use any JSON lib you like.

Does that help?

Cheers,
Martin

Am 21.11.11 19:41, schrieb mikes:


> Can anyone give me pointers on how to create custom JSON(custom
> provider) using JAXRS in Grails?
>
> thanks

--
Martin Krasser

blog: http://krasserm.blogspot.com
code: http://github.com/krasserm
twitter: http://twitter.com/mrt1nz

mikes

unread,
Nov 23, 2011, 4:39:20 PM11/23/11
to grails-jaxrs-discuss
Thanks, Martin. That's really helpful. I wrote a custom provider to
create custom JSON. That works great!

I need to now work on the PUT/POST stuff. Any pointers on this would
be really helpful.

Thanks again!


On Nov 22, 5:33 am, Martin Krasser <krass...@googlemail.com> wrote:
> Hi mikes,
>
> here's an incomplete list of options:
>
> - Resource methods can return instances of grails.converters.JSON. The
> grails-jaxrs plugin has a provider for converting between JSON

> representations and grails.converters.JSON objects (see alsohttp://code.google.com/p/grails-jaxrs/wiki/AdvancedFeatures#Entity_pr...)


>    * JSON instances can be created by calling 'as JSON' on a Grails
> domain objects
>    * JSON instances can also be created with grails.web.JSONBuilder:
> With JSONBuilder you can create any custom JSON repsonse you like
>

> - If you want to write a custom provider please take a look athttp://code.google.com/p/grails-jaxrs/wiki/AdvancedFeatures#Custom_pr...

Martin Krasser

unread,
Nov 24, 2011, 11:18:37 AM11/24/11
to grails-jax...@googlegroups.com

Am 23.11.11 22:39, schrieb mikes:


> Thanks, Martin. That's really helpful. I wrote a custom provider to
> create custom JSON. That works great!
>
> I need to now work on the PUT/POST stuff. Any pointers on this would
> be really helpful.

I guess you already read the JAX-RS spec and the Jersey docs. Do you
have any specific question or problem?

Reply all
Reply to author
Forward
0 new messages