Javascript中的JSON diff

时间:2018-06-18 16:57:44

标签: javascript jquery json

我已经构建了一个系统,AJAX每5秒轮询一次服务器以获取新数据。然后,客户端将最初在浏览器中加载的JSON的大小与新轮询的数据的大小进行比较。如果存在差异,则会加载新数据并将其存储在浏览器中。这每5秒重复一次。

如何获取已更新的JSON字段(例如diff)的名称和值以及对象的id。示例如下:

{  
   "calls":[  
      {  
         "call_id":"464",
         "status":"In Progress",
         "postcode":"XXXX XXXX",
         "address":"Place, 58 Street, London",
         "initial_call_category":"",
         "date":"2018-05-01 22:48:58",
         "phone1":"62919101192"
      },
      {  
         "call_id":"463",
         "status":"Closed",
         "postcode":"XXXX XXXX",
         "address":"Place, 53 Street, London",
         "date":"2018-05-13 19:12:34",
         "phone1":"07946234345"
      },
   ]
}

call_status更新call_id 464时,我想打印出关键字和新值(即"call_status": "Complete"),我还想打印出call_id更新与("call_id":"464")有关。

我该怎么做?

0 个答案:

没有答案