0

As you see in the image:

enter image description here

I've a array of object I think there is JSON array. I want to get only "productThumbnailUrl" on this array and use that in another way.

Can anyone help me to get this value and store it in a separate variable.

It's has multiple rows on the array. I only want get "productThumbnailUrl".

subir biswas
  • 371
  • 2
  • 5
  • 14
  • 3
    Possible duplicate of [Accessing Objects in JSON Array (JavaScript)](http://stackoverflow.com/questions/14217790/accessing-objects-in-json-array-javascript) – Mario Santini Dec 23 '16 at 07:06

3 Answers3

1

var x = JSON.parse('{"productThumbnailUrl": "val1", "key2": "val2", "key3": "val3", "key4": "val4"}');

alert (x['productThumbnailUrl']);

var y = x['productThumbnailUrl'];

Dip Parmar
  • 312
  • 1
  • 13
1

You can use For loop to loop json data

for(x in json) {
    console.log(json[x].productThumbnailUrl);
}
bugscoder
  • 425
  • 2
  • 6
0

Let's consider your main array is

var products= [your product arr];
products.forEach(
function(product){
console.log(product["productThumbnailUrl"]);
});

it will list your productThumbnailUrls. it will loop through all items.

  • `var json = $.cookie('cartArray'); var parsed = JSON.parse(json); var arr = []; for(var x in parsed){ arr.push(parsed[x]); } for(var i = 0; i – subir biswas Dec 23 '16 at 11:00