问题
I have a string that carry the path of a nested json, where I need to update a value
var path = 'p_Data[0]["BusinessUnit"][0]["BusinessUnit"]'
if i evaluate this path I get value as 'Unit1'. I need to update the value 'Unit1' with 'Closed' and retrieve the original data ie, p_Data
I tried eval(path = 'Closed')
, but didn't work.
How to do this?
回答1:
eval(path + "='Closed'");
But have a look at this thread: Why is using the JavaScript eval function a bad idea?.
来源:https://stackoverflow.com/questions/18098594/jquery-set-value-for-the-json-path-provided-as-string