1
I have the following JSON:
{
  "$SP": {
    "0": "92",
    "1": "00:01:36.340",
    "2": "00:05:48.929\n"
  },
  "$MT": {
    "0": "91",
    "1": "00:00:34.187",
    "2": "00:18:44.001\n"
  }
}
I need a function that looks for the key name and then looks for a number inside it, and returns the whole object. For example:
json("$MT", "91");
expected return:
"$MT": {
            "0": "91",
            "1": "00:00:34.187",
            "2": "00:18:44.001\n"
        }
I have the following function:
var json = {}; 
function addJson(data){
   var chave; 
   for(var i in data){
      if(i == 0){ 
         chave = data[i]; 
         json[chave] = {}; 
      }else{
         json[chave][i-1] = data[i]; 
      }
   }
}
But only one key returns to me.
You could better explain your problem by crafting a better example?
– Leandro Angelo
i receive this json every second, I need to filter for the first key that would be in the "$MT" example and then a second filter for the value "91" and the expectation is to resume the whole object so that I can use the other values of it
– Monogarm
It would be good for you to give more examples because it’s hard to understand
– Sorack