Recursively parse JSON properties

by Aieman Siddique

JavaScript

var data = {
  "days": [
    {"day1" : {"FDI": 6, "Temp": 22.5, "RH": 94.8, "Wind": 20.8, "FMC": 16}
    }
  ],
  "something": "abcd"
}

function jsonRecursive(json1) {
  for(prop in json1) {
    var x = typeof(json1[prop]);
    console.log(prop + ': ' + x);
  
        switch(typeof(json1[prop])) {
        case "object":
        		console.log('object property: ');
            console.log(json1[prop]);
            jsonRecursive(json1[prop]);
          break;
        default:
             //console.log('other type property: ');
             //console.log(json1[prop]);
          break;
      }
  }
}


jsonRecursive(data);