Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

JavaScript: Convert javascript object to json string

JSON.stringify(object) method converts JavaScript Object to JSON string.

stringify.html




Convert Java object to string



String format of employees object is
id="data">



"text/javascript">
var employees = [{
"firstName": "Hari Krishna",
"lastName": "Gurram",
"age": 27
}, {
"firstName": "Kiran Kumar",
"lastName": "Darsi",
"age": 28
}];

var str = JSON.stringify(employees);
document.getElementById("data").innerHTML = str;





Open above page in browser, you can able to see following text.

String format of employees object is

[{"firstName":"Hari Krishna","lastName":"Gurram","age":27},{"firstName":"Kiran Kumar","lastName":"Darsi","age":28}]




Previous                                                 Next                                                 Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

JavaScript: Convert javascript object to json string

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×