How would I return the following string as an object
{src:'img/testimage.jpg', coord : {x:17, y:39}, width:200, height, 200}
update
I have a php file that outputs JSON. I've used AJAX to to access the JSON in my js.
I've used JSON.parse(json_string) so I now have my object. This what is returned:
[{"name":"img","attributes":"{src:'img\/testimage.jpg', coord : {x:17, y:39}, width:200, height, 200}","comments":"image element with attributes"},{"name":"triangle","attributes":"{bgColor : '#FF0000', coord : {x:500, y:300}, width:50, height, 50}","comments":"triangle"}]
I can now use a for loop to go through the bits.
for(key in json_object) {
var name_type = json_object[key].name;
var attrib = json_object[key].attributes;
}
here attrib returns
{src:'img/testimage.jpg', coord : {x:17, y:39}, width:200, height, 200}.
It is this string that I need to convert into an object.
Thanks Dave