📜  从 json stigify 中排除属性 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:29.560000             🧑  作者: Mango

代码示例1
function replacer(key,value)
{
    if (key=="privateProperty1") return undefined;
    else if (key=="privateProperty2") return undefined;
    else return value;
}

var x = {
    x:0,
    y:0,
    divID:"xyz",
    privateProperty1: 'foo',
    privateProperty2: 'bar'
};

alert(JSON.stringify(x, replacer));