Difference in JSON objects using Javascript/JQuery

后端 未结 5 2090
我在风中等你
我在风中等你 2020-11-27 15:50

I have two JSON objects in Javascript, identical except for the numerical values. It looks like this:

var data = {
  \"eth0\":{\"Tx\":\"4136675\",\"Rx\":\"13         


        
5条回答
  •  孤城傲影
    2020-11-27 16:09

    The basic premise for iterating over objects in JavaScript is like so

    var whatever = {}; // object to iterate over
    for ( var i in whatever )
    {
      if ( whatever.hasOwnProperty( i ) )
      {
         // i is the property/key name
         // whatever[i] is the value at that property
      }
    }
    

    Fixing up a checker wouldn't be too hard. You'll need recursion. I'll leave that as an exercise for you or another SOer.

提交回复
热议问题