Re: [json-lib-user] JsonGroovyBuilder examples
Brought to you by:
aalmiray
|
From: Kevin S. <kev...@gm...> - 2008-06-05 21:14:17
|
Please disregard this question.
Of course after I sent this email I tried 'println myJson.toString()'
instead of just 'println myJson'. When doing 'println myJson.toString()'
the json output is indeed correct.
Thanks,
Kevin
On Thu, Jun 5, 2008 at 4:00 PM, Kevin Shekleton <kev...@gm...>
wrote:
> Using:
> * json-lib-2.2.1-jdk15.jar
> * groovy-all-minimal-1.5.6.jar
>
> The current JsonGroovyBuilder javadoc [1] gives 6 examples for constructing
> a Books object. Quoting from the javadoc:
>
> *all 6 books variables output the same JSON
>
> {"books": {
> "book": [{
> "title": "The Definitive Guide to Grails",
> "author": "Graeme Rocher"
> },{
> "title": "The Definitive Guide to Grails",
> "author": "Graeme Rocher"
> }]
> }
> }*
>
> However, when I try all 6 examples from the javadoc, the json produced is
> different. Namely, rather than being objects {}, the output is arrays [].
>
> *["books": [
> "book": [[
> "title":"The Definitive Guide to Grails",
> "author":"Graeme Rocher"
> ],[
> "title":"The Definitive Guide to Grails",
> "author":"Graeme Rocher"
> ]]
> ]
> ]*
>
> Is this expected behavior?
>
> Thanks,
> Kevin
>
> [1]
> http://json-lib.sourceforge.net/apidocs/jdk15/net/sf/json/groovy/JsonGroovyBuilder.html
>
|