eg if variable jsonstring contains
{"prod_name":"GM","quantity":100,"price":54.5,"type":"Limit"}
for a code like
   var obj= JSON.parse(jsonstring);
Without knowing the string content is there a way to extract the property/ value names?
eg if variable jsonstring contains
{"prod_name":"GM","quantity":100,"price":54.5,"type":"Limit"}
for a code like
   var obj= JSON.parse(jsonstring);
Without knowing the string content is there a way to extract the property/ value names?
 
    
     
    
    You can loop through the object properties.
for ( var prop in obj ) {
    if ( obj.hasOwnProperty(prop) ) {
        console.log( prop + ': ' + obj[prop] );
    }
}
 
    
    In JavaScript 1.8.5, Object.getOwnPropertyNames returns an array of all properties found directly upon a given object.
Object.getOwnPropertyNames ( obj )
