Skip to content

Instantly share code, notes, and snippets.

@pmn4
Created April 10, 2014 14:45
Show Gist options
  • Select an option

  • Save pmn4/10389909 to your computer and use it in GitHub Desktop.

Select an option

Save pmn4/10389909 to your computer and use it in GitHub Desktop.
JSON.stringify takes Parameters
var o = {
a: 1,
b: 2,
c: 3,
d: {
a: 5,
b: 6
}
};
console.log("1 Parameter: Render a JSON string");
console.log(JSON.stringify(o));
console.log("2 Parameters: Render a JSON string for the given set of keys");
console.log(JSON.stringify(o, ["a", "b"]));
console.log("3 Parameters: Render a JSON string for the given set of keys, with the given indentation");
console.log(JSON.stringify(o, ["a", "b"], 4)); // === JSON.stringify(o, ["a", "b"], " ");
// DEBUG THE PLANET!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment