About the pit that javascript has stepped on

      Foreword:

      Recently, I encountered a pit when I was working on a project to write JS. When I got the value of the JSON object, I found that the key in the JSON object was "xxx.xxx", such as "task.taskId" in the following code:

var obj = {

      activityName:"eee",

      historicProcessInstance.id:" ",

      id:"daa84b785d714930b4bf24a47adf2816",

      task.taskId:"147624",

      taskOrgId:"b0f90c0d8e1b4cd793cc8501b716e2e0",

      totalMoney:"0",

}

     Problem encountered: When the value of this field is obtained through obj.task.taskId, the taskId property under the task object under the obj object is searched, then the above JSON object cannot be parsed at this time;

     Solution: When parsing the attribute value of this type (containing .), you can use obj["task.taskId"] to get the value of this field

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326292529&siteId=291194637