generic / variable reference to json array field name
607218Nov 23 2009 — edited Nov 24 2009hi -- I have a javascript function that I want to make variable-based, so it can be used throughout my application.
It creates and parses a json object. I ultimately need to reference a field in that object. The field name is the name of database column
that was queried in the called application process.
For example, if the query executed was: select my_id from my_table where my_name = 'the_name', and the object that holds the parsed
AJAX response is jsonobj, then I need to reference: jsonobj.row[0].my_id
I don't want my_id to be hardcoded in the reference. Rather, I want to pass the string 'my_id' into the javascript function (let's call
the variable dest_item_name) and then reference (something like): jsonobj.row[0].<dest_item_name>.
(How) can I do this? Please tell me I can! :)
Thanks,
Carol