I'm currently using Simplecart.js to store items into local storage. The JSON below is what I'm working with. I need to parse just the thumb and name, then display them on the browser using jQuery. what's the best approach in achieving this?
{
"SCI-1": {
"quantity" : 1,
"id" : "SCI-1",
"name" : "item1",
"thumb" : "http://www.example.com/img/1.jpg",
"url" : "http://www.example.com/1/",
"thumbnail" : "http://www.example.com/img/thumbnail/1.jpg",
"size" : "10x10"
},
"SCI-2": {
"quantity" : 1,
"id" : "SCI-2",
"name" : "item2",
"thumb" : "http://www.example.com/img/2.jpg",
"url" : "http://www.example.com/2/",
"thumbnail" : "http://www.example.com/img/thumbnail/2.jpg",
"size" : "20x20"
},
"SCI-3": {
"quantity" : 1,
"id" : "SCI-3",
"name" : "item3",
"thumb" : "http://www.example.com/img/3.jpg",
"url" : "http://www.example.com/3/",
"thumbnail" : "http://www.example.com/img/thumbnail/3.jpg",
"size" : "30x30"
}
}
The console output below returns the object:
var item = JSON.parse( localStorage.getItem( 'simpleCart_items' ) );
console.log( item );