Created
February 17, 2014 19:57
-
-
Save stewart/9057871 to your computer and use it in GitHub Desktop.
Stringify supports pretty-printing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var object = { | |
vendorId: 6708, | |
productId: 515, | |
analogSticks: [ | |
{ name: "left", x: 6, y: 7 }, | |
{ name: "right", x: 8, y: 9 } | |
], | |
}; | |
JSON.stringify(object); | |
//=> {"vendorId":6708,"productId":515,"analogSticks":[{"name":"left","x":6,"y":7},{"name":"right","x":8,"y":9}]} | |
JSON.stringify(object, null, 2); | |
// => { | |
// => "vendorId": 6708, | |
// => "productId": 515, | |
// => "analogSticks": [ | |
// => { | |
// => "name": "left", | |
// => "x": 6, | |
// => "y": 7 | |
// => }, | |
// => { | |
// => "name": "right", | |
// => "x": 8, | |
// => "y": 9 | |
// => } | |
// => ] | |
// => } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment