I've been trying to save a self contained javascript object to JSON, but when using eval
or JSON.parse()
it gets rid of the anonymous function
let test = '({"a":1000, "b":()=>{return console.log("hello");}})';
test = eval(test);
console.log(test);
Output:
[LOG]: {
"a": 1000
}
I'm making an API and I would like to export the whole object including the function, is it possible to export the raw code even if it's not a JSON per se?
Thank you in advance