Created
June 26, 2013 02:36
-
-
Save ruedesign/5864328 to your computer and use it in GitHub Desktop.
Build JSON in Grails using groovy.json.JsonBuilder(Groovy API)
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 code = null | |
def message = "error message" | |
def builder = new JsonBuilder() | |
def root = builder { | |
error( | |
code: code ?: "", | |
message: message ?: "" | |
) | |
} | |
assert builder.toString() == '{"error":{"message":"error message","code":""}}'' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment