I know that JSON.stringify converts objects to serialized strings. But the output string is a mixture of property names, paired with values. Is there a way to extract only column names from objects?
Here is an example to help you understand what I want to achieve.
var student = {
id : 12345,
full_name: "mike smith",
address : "26, Dmm St.",
email : "mike@something.co",
grade : "B+"
};
$.each(student,function(i,column){
console.log('The value is :' + column );
});
this will output :
The value is :12345
The value is :mike smith
The value is :26, Dmm St.
The value is :mike@something.co
The value is :B+
I am trying to display the information on a page, but want to the column name to be an attribute hidden from the user (for sorting purposes).
I tried: console.log('The value of ' + typeof column + ' is ' + column);
put that just outputs
The value of string is B+
Is there a way to include the column name inside the string?
Desired output:
The value of id is :12345
The value of full_name is :mike smith
The value is address :26, Dmm St.
The value is email :mike@something.co
The value is grade :B+
Aucun commentaire:
Enregistrer un commentaire