Skip to content

Instantly share code, notes, and snippets.

@cgkio
Created September 30, 2013 18:54
Show Gist options
  • Save cgkio/6768340 to your computer and use it in GitHub Desktop.
Save cgkio/6768340 to your computer and use it in GitHub Desktop.
building/modifying JSON with javascript
// https://developer.mozilla.org/en-US/docs/JSON
var foo = {};
foo.bar = "new property";
foo.baz = 3;
var JSONfoo = JSON.stringify(foo);
// JSONfoo now holds {"bar":"new property","baz":3}
// To make JSONfoo back into a JavaScript object just do:
var backToJS = JSON.parse(JSONfoo);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment