1function replacer(key,value)
2{
3 if (key=="privateProperty1") return undefined;
4 else if (key=="privateProperty2") return undefined;
5 else return value;
6}
7
8var x = {
9 x:0,
10 y:0,
11 divID:"xyz",
12 privateProperty1: 'foo',
13 privateProperty2: 'bar'
14};
15
16alert(JSON.stringify(x, replacer));
17