Convert objects to strings for code generation
See all valid object properties and limitations here
import { stringifyObject } from 'obj-string'
let str = stringifyObject({
data: {
list: [0,2,4,6,8],
nested: {
value: 4
}
},
method(param){
console.log(param)
}
})
console.log(str)
/*
{
"data":{
"list":[0,2,4,6,8],
"nested":{
"value":4
}
},
"method": function (param){
console.log(param)
}
}
*/
Code heavily inspired by stringified-handler
MIT © Marshall Brandt