why use JSON to store functions? use JS at this point. you can even convert it to some sorta codegen tool by replacing ;(
)
wrapper with something like export default(
)
and have a valid javascript file that your lsp can read and give you insight about.
function jsave(obj) {
if (typeof obj !== "object") return `${eval(obj)}`
let result = "{ "
for (const [key, val] of Object.entries(obj))
result += `${key}: ${jsave(val)}, `
result += " }"
return result
}
const obj = { a: 9, utils: { double: t => t * 2 } }
const file = `;(${ jsave(obj) })`
console.log(file)
const loaded = eval(file)
console.log(obj.utils.double(3))
console.log(loaded.utils.double(3))