public class JsonGroovyBuilder
extends groovy.lang.GroovyObjectSupport
def books1 = builder.books {
book = [title: "The Definitive Guide to Grails", author: "Graeme Rocher"]
book = [title: "The Definitive Guide to Grails", author: "Graeme Rocher"]
}
def books2 = builder.books {
book = new Book(title: "The Definitive Guide to Grails",
author: "Graeme Rocher")
book = new Book(title: "The Definitive Guide to Grails",
author: "Graeme Rocher")
}
def books3 = builder.books {
book = {
title = "The Definitive Guide to Grails"
author= "Graeme Rocher"
}
book = {
title = "The Definitive Guide to Grails"
author= "Graeme Rocher"
}
}
def books4 = builder.books {
book {
title = "The Definitive Guide to Grails"
author= "Graeme Rocher"
}
book {
title = "The Definitive Guide to Grails"
author= "Graeme Rocher"
}
}
def books5 = builder.books {
2.times {
book = {
title = "The Definitive Guide to Grails"
author= "Graeme Rocher"
}
}
}
def books6 = builder.books {
2.times {
book {
title = "The Definitive Guide to Grails"
author= "Graeme Rocher"
}
}
}
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"
}]
}
}
| Constructor and Description |
|---|
JsonGroovyBuilder() |
| Modifier and Type | Method and Description |
|---|---|
JsonConfig |
getJsonConfig() |
java.lang.Object |
getProperty(java.lang.String name) |
java.lang.Object |
invokeMethod(java.lang.String name,
java.lang.Object arg) |
void |
setJsonConfig(JsonConfig jsonConfig) |
void |
setProperty(java.lang.String name,
java.lang.Object value) |
public JsonConfig getJsonConfig()
public void setJsonConfig(JsonConfig jsonConfig)
public java.lang.Object getProperty(java.lang.String name)
getProperty in interface groovy.lang.GroovyObjectgetProperty in class groovy.lang.GroovyObjectSupportpublic java.lang.Object invokeMethod(java.lang.String name,
java.lang.Object arg)
invokeMethod in interface groovy.lang.GroovyObjectinvokeMethod in class groovy.lang.GroovyObjectSupportpublic void setProperty(java.lang.String name,
java.lang.Object value)
setProperty in interface groovy.lang.GroovyObjectsetProperty in class groovy.lang.GroovyObjectSupportCopyright © 2006-2013 Json-lib. All Rights Reserved.