Created
July 31, 2014 15:22
-
-
Save lotsofcode/90dfd4e4a8738c4d571b to your computer and use it in GitHub Desktop.
JSON stringify replacer
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
| // @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