Created
February 12, 2016 12:41
-
-
Save batmat/52564560891360b9737d to your computer and use it in GitHub Desktop.
Sample Groovy code to transform a Map into a Json output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def someMap = [ | |
'key1': "value", | |
'key2': 142.1 | |
] | |
def json = new groovy.json.JsonBuilder() | |
json rootKey: someMap | |
println "json output: " | |
println groovy.json.JsonOutput.prettyPrint(json.toString()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Displays: