Skip to content

Instantly share code, notes, and snippets.

@lotsofcode
Created July 31, 2014 15:22
Show Gist options
  • Select an option

  • Save lotsofcode/90dfd4e4a8738c4d571b to your computer and use it in GitHub Desktop.

Select an option

Save lotsofcode/90dfd4e4a8738c4d571b to your computer and use it in GitHub Desktop.
JSON stringify replacer
// @ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Parameters
function censor(key, value) {
if (typeof value === "string") {
return undefined;
}
return value;
}
var foo = {
foundation: "Mozilla",
model: "box",
week: 45,
transport: "car",
month: 7
};
var jsonString = JSON.stringify(foo, censor);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment