Here is my code:
BAD = {
"a": "2",
"b": 1,
"c": "Nexus",
"d": "Alligator",
"e": 5,
"f": 1431807036,
"g": {
"2": {
"w": 17,
"b": 5
}
}
}
console.log(JSON.stringify(BAD, ['a', 'b', 'c', 'd', 'e', 'g']));
http://jsfiddle.net/whv7x6xc/1/
The keys a
, b
, c
, d
, e
, and g
are the only ones being stringified which is nice, but there is one problem. It's ignoring the object that is assigned to g
.
But, if you do: console.log(JSON.stringify(BAD));
it shows the proper stringified version.
Edit: w
and b
are dynamic and changed periodically (come and go) though, so I cannot just hard-code them in.