Using the JSONGroovyBuilderPage edited by Justin Edelsonupdating to reflect automatic bindingThe extensions.groovy bundle includes a Groovy Builder which makes it easy to create JSON documents from Sling scripts. This code is inspired by the builder contained in Andres Almiray's json-lib project (http://json-lib.sourceforge.net/). However, Sling's builder is not compatible with the json-lib builder. An instance of this class is available to all Groovy scripts as a variable named jsonBuilder. A basic script looks like this:
out.write jsonBuilder.json {
text currentNode.getProperty("text").string
} as String
Change Notification Preferences
View Online
|
View Change
|
Add Comment
|
- [CONF] Apache Sling > Using the JSONGroovyBuilder confluence
- [CONF] Apache Sling > Using the JSONGroovyBuilder confluence
- [CONF] Apache Sling > Using the JSONGroovyBuilder confluence
- [CONF] Apache Sling > Using the JSONGroovyBuilder confluence
