I need to render in code mirror ( a plugin to display code snippets in the frontend ) an object containing functions, my object looks like:
{
lang:"en",
func1: function(e){
console.log(e);
},
func2: function(f){
alert(f);
}
}
I've tried using JSON.stringify with a replace, like:
JSON.stringify(finalGlobalConfigObj, function(key, value) {
if (typeof value === "function") {
return "/Function(" + value.toString() + ")/";
}
return value;
}, 4);
However, the rendering is not great because it just render the content as a String.
How can I render correctly my object that is containing functions?
I'm using code mirror inside an angular application.