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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -