stringify
JSON
class method
JS Home <<
JS Reference <<
JSON <<
stringify
Description
Converts a value to JSON format.
- Like all class methods
stringify()
should be used on the class rather than an instance of the class.
Syntax
Signature | Description |
---|---|
JSON.stringify(someText[, transformer [, space]]) | Converts a value to JSON format. |
Parameters
Parameter | Description |
---|---|
someText | The value you wish to parse to JSON format. |
transformer | Computed value transformed prior to return:
|
space | Result will be a 'pretty-printed' formatted string. |
Examples
// Store properties in an array.
function HomeOwner(firstName,lastName) {
this.firstName=firstName;
this.lastName=lastName;
}
var ownerList = new Array(3);
ownerList[0] = new HomeOwner('Barney','Magrew');
ownerList[1] = new HomeOwner('Manny','Simon');
ownerList[2] = new HomeOwner('Arnie','Padrew');
alert('The list of objects we created: ' + ownerList);
alert('The list of objects we created Stringified: '
+ JSON.stringify(ownerList));
Related Tutorials
JavaScript Intermediate Tutorials - Lesson 7 - Object Literals