Answers for "excluding a attribute from json strigify"

0

excluding a attribute from json strigify

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));
Posted by: Guest on April-16-2021

Code answers related to "excluding a attribute from json strigify"

Code answers related to "Javascript"

Browse Popular Code Answers by Language