How to retrieve key and value from JSON String
If I understood the question correctly, I think you might want to use something along this:
var jsonArray = ... ; // {"supplier": ... } (JS Object)var supplierOptions = jsonArray.supplier;// TODO: remember to set up selectme!for(var optionId in supplierOptions) { if(!supplierOptions.hasOwnProperty(optionId)) { continue; } var optionValue = supplierOptions[optionId]; // operate with name and value here (append to select ie.) $("#selectme").append('<option id="' + optionId + '">' + optionValue + '</option>');}
The code probably could use some cleaning up. Hopefully it conveys the basic idea, though.