Languages
[Edit]
EN

JavaScript - serialize object to json

12 points
Created by:
Kate_C
19790

In JavaScript script it is possible to serialize object to json in following way.

1. JSON.stringify method example

// ONLINE-RUNNER:browser;

var studentObject = {
    name: 'John',
    age: 25,
    todos: [
        'Sleeping',
        'Lectures',
        'Classes',
        'Shopping'
    ]
}

var studentJson = JSON.stringify(studentObject);

console.log(studentJson);

Note: JSON.stringify method has been introduced in ES5.

See also

  1. JavaScript - deserialize json to object 
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join