I am attempting to transform a JSON file into an object within my application, complete with embedded functions. However, I am facing difficulties in accomplishing this task. The JSON file causing issues is as follows:
{
"draw": function() {
ctx.clearRect(0,0,960,720);
ctx.fillStyle = "#000000";
},
"load": function() {
if (beginning = 0) { erasePrev };
loadHTML('button','level1Button',"position:absolute; top:100px; left:200px;",'LEVEL I','loadLevel(1)',false,false);
loadHTML('a','howtoplayhref',"position:absolute; top:100px; left:100px;",'how to play',false,false,'howtoplay.html');
},
"clear": function() {
removeHTML(level1Button);
removeHTML(howtoplayhref);
}
}
While I have the knowledge of how to load and parse the file, the problem arises when it fails to validate as a proper JSON format.