In our Angular 5 project, we are facing an issue with loading a .json file in a .ts file using XMLHttpRequest.
The content of the .json file is as follows:
{
stringKey: "stringValue",
functionKey: function() {
console.log('function called!')
}
}
An error is being thrown: [json] value expected.
When setting the object in Chrome Devtool, it works fine, but not within the project itself.
If I open Chrome Devtool and set the above object as value - it works fine but not in the project
var obj = {
stringKey: "stringValue",
functionKey: function() {
console.log('function called!')
}
}
obj.functionKey();
Edit:
Is there a workaround for storing functions in pure JSON?