Javascript Object Convert to Json with white list

Description

Javascript Object Convert to Json with white list


let whitelist = [ "test", "test2" ];

let obj2 = {//from w w  w.  j  av a2s.  co m
  "test" : "value1",
  "test2" : 3.44,
  "test3" : false
};
 jsonobj = JSON.stringify(obj2, whitelist, "***");

console.log(jsonobj); // not test3



PreviousNext

Related