'Search Key in Nested json in Dart/Flutter

I want to search the key "AylaHeartBeatFrequency" inside nested json. how to search and get its value ? in flutter/dart

{
  "sAWSIoT": {
    "CloudStatus": 1,
    "PairingFlag": 0,
  },
  "sDebug": {
    "LocalDebugMsg_d": "Model ID",
    "AylaHeartBeatFrequency": 0
  },
  "Product": {
    "Mode": 1,
    "Model": "abc"
  },
  "data": {
    "DeviceType": 300,
    "Endpoint": 0,
    "UniID": "0000000000000000"
  }
}


Solution 1:[1]

You can do:

var map = /*put your json here. You can use json.decode() on the json if it's not yet formatted*/, value;
for(var item in map.values) {
  if(item.containsKey('AylaHeartBeatFrequency') value = item['AylaHeartBeatFrequency']) ; 
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fsbelinda