Insert array of json data into json file using javascript & JSP -


i have 1 function in code gives me x & y coordinates. have formatted data , saved data array in json format. now, want save variable data json file. can me out this? variable arraydata contains string of json data want save new json file. or can use jsp save data json file? problem here is, data in javascript variable.

game.input.ondown.add(function() {     x = math.floor(game.input.activepointer.worldx / 15);     y = math.floor(game.input.activepointer.worldy / 15);     arraydata.push("{'x':'" + x+"','y':'"+y+"'}");     document.getelementbyid('test').innerhtml = ' data: {"x":' + x+',"y":'+y+'}';     console.log(" data: " + arraydata); }); 

you don't have put object between quotes: string. change:

arraydata.push("{'x':'" + x+"','y':'"+y+"'}"); 

to:

arraydata.push({'x': x,'y': y}); 

which equivalent to:

var obj = {     'x': math.floor(game.input.activepointer.worldx / 15),      'y': math.floor(game.input.activepointer.worldy / 15) }; arraydata.push(obj); 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -