JQuery set value for the json: path provided as string

﹥>﹥吖頭↗ 提交于 2019-12-11 07:46:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!