Created
December 6, 2017 07:44
-
-
Save ferdiemmen/54a12e92ac328d40ceee20e8067cab44 to your computer and use it in GitHub Desktop.
Json stringify ignores keys whose values are undefined
This file contains 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 breakfast = { | |
"cereal" : "fruit loops", | |
"pastry" : undefined | |
}; | |
console.log(breakfast); | |
// -> { cereal: 'fruit loops', pastry: undefined } | |
console.log(JSON.stringify(breakfast)); | |
// -> {"cereal":"fruit loops"} | |
https://stackoverflow.com/questions/31284216/why-does-json-stringify-ignore-keys-whose-values-are-undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment