JSON . null. undefined JavaScript , .
JSON , , , JavaScript. '
,
var x = { foo: undefined };
x.foo === undefined;
var json = JSON.stringify(x);
var y = JSON.parse(json);
y.foo === undefined;
, JSON.stringify , x.
. JSON.stringify
, JSON,
. , .
, , JSON.stringify replacer
, .
, JSON.stringify undefined:
var replacer = function(key, value){
if(value === undefined){
throw 'JSON.stringify: bad property: ' + key;
}
return value;
};
var x = {foo: undefined};
JSON.stringify(x, replacer);
null:
var replacer = function(key, value){
if(value === undefined){
return null;
}
return value;
};
var x = {foo: undefined};
JSON.stringify(x, replacer);