jquery - how can I remove quotes from array -


 $.getjson('data.json', function(data) {         var arr = [];          for(var = 0, j = data.length; < j; i++)         {             var param = data[i];              if(param['p'] == 'levela')             {             arr.push('{"x":'+param['t']+','+'"y":0'+','+'"h":'+param['v']+','+'"w":1,'+'"bg":"magenta"}');             }            }     }) 

this code return

["{"x":5.07527,"y":0,"h":0,"w":1,"bg":"magenta"}", "{"x":5.08601,"y":0,"h":7,"w":1,"bg":"magenta"}", "{"x":5.09164,"y":0,"h":12,"w":1,"bg":"magenta"}", "{"x":5.10255,"y":0,"h":19,"w":1,"bg":"magenta"}", "{"x":5.11356,"y":0,"h":26,"w":1,"bg":"magenta"}".... 

i need remover "", transforme

"{"x":5.07527,"y":0,"h":0,"w":1,"bg":"magenta"}" 

to {"x":5.07527,"y":0,"h":0,"w":1,"bg":"magenta"}

don't push string arr, push object:

arr.push({ x: param.t, y: 0, h: param.v, w: 1, bg: "magenta" }); 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -