How to parse a JSON file in javascript without having any knowledge about the contents of the file? -


this question has answer here:

i know how parse json file irrespective of contents. example, have parse following json. how parse , call values without using words/keys json file?

var = [{     "master row": "p558:15",     "prefix*": "5c34",     "base*": "1508",     "suffix*": "ca",     "weight unit of measure": "lb" }, {     "master row": "p558:16",     "prefix*": "5c34",     "base*": "1508",     "suffix*": "ca",     "weight unit of measure": "lb" }] 

you need loop go through each element in a, , loop go through each key in objects. (also missing comma between prefix , base in first object)

var a= [ { "master row":"p558:15", "prefix*":"5c34","base*":"1508", "suffix*":"ca", "weight unit of measure":"lb" }, { "master row":"p558:16", "prefix*":"5c34", "base*":"1508", "suffix*":"ca", "weight unit of measure":"lb" } ];    for(i=0;i<a.length;i++){    var temp=a[i];    for(key in temp){      console.log(key+' '+temp[key]);    }  }


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -