I have some JSON returned to the browser like this \"product\":
{ \"Title\": \"School Bag\", \"Image\": \"/images/school-bag.jpg\" }
I want
Simple, if I got it,
var json = { "Title": "School Bag", "Image": "/images/school-bag.jpg" }
function Product(json) {
this.img = document.createElement('img');
this.img.alt = json.Title;
this.img.src = json.Image;
this.toHTMLImage = function() {
return this.img;
}
}
var obj = new Product(json); // this is your object =D