(Quick Reference)
Purpose
Retrieve and convert the
Smartionary
into a JSON string.
Example
try {
Smartionary.getAsJson('fruits')
} catch (IllegalArgumentException e) {
// Smartionary may not exist.
} catch (JsonException e) {
// Something went awry.
}
try {
Smartionary.getAsJson('fruits', true)
} catch (IllegalArgumentException e) {
// Smartionary may not exist.
} catch (JsonException e) {
// Something went awry.
}
Description
Uses the
Groovy JsonBuilder to convert the
Smartionary
into JSON.
When passed
true
, the JSON is pretty-formatted. By default, this condition
is
false
.
Calling getAsJson()
and providing a smartionaryName
that is not actually
present in the Smartionary
domain will throw an IllegalArgumentException
.If there is a chance that the Smartionary
may get deleted, then use a
try/catch
statement.