grails - How do I generically access this Groovy JSON object? -
i'm using grails 1.3.6. read following json variable ...
{ "abc": { "attr1": "value1", "attr2": "value2" }, "def": { "attr1": "value1", "attr2": "value2" }, "ghi": { "attr1": "value1", "attr2": "value2" }, ... }
if, in controller, i'm passed parameter referring 1 part of json object ...
def section = params.section; // "abc", "def", 'ghi", ...e
how access part of json assuming above gets stored groovy variable named "myjsonobject"? thanks, - dave
if used json.parse()
create myjsonobject
, can do:
def value = myjsonobject[section]
Comments
Post a Comment