Fetching a specific field value within in the nested properties of JSON formatted data.

Posted 1 year ago by rameezisrar

Below is the JSON returned data of a product from my store. How can i fetch a specific property with in this nested data i.e How can i fetch the 'featured_image' value of the first 'variant' property ?

{
  "products": [
    {
      "id": 568633786416,
      "title": "Black Panther Bracelet",
      "handle": "black-panther-bracelet",
      "body_html": "<p style=\"margin-bottom: 1em; line-height: 1.4; color: #000000; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px;\">The Black Panther has become a global favorite due to its portrayal and educated exposure to African cultural heritage, with beautiful stylish connotations. T'Challa and his friends can be seen wearing such beautiful craftwork jewelry in the new adaptation of Wakanda's <strong>Black Panther.</strong></p>\n<p style=\"margin-bottom: 1em; line-height: 1.4; color: #000000; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px;\">The beaded <strong>bracelet</strong> has been designed using alloy stones, plated in a flawless matte-reflective shine, the cultural style beaded necklace will give you a new attitude for winning and skill, just like the Wakandan nation. <br>The necklace is an urban trend apparel with a touch of sophisticated vintage zeal. <br>Available now for sale</p>\n<p> </p>\n<ul>\n<li>Item Type: <strong>Bracelets</strong>\n</li>\n<li>Material: <strong>Stone</strong>\n</li>\n<li>Gender: Women</li>\n<li>Shape\pattern: Geometric</li>\n<li>Chain Type: Beaded Bracelet</li>\n<li>Clasp Type: Lace-up</li>\n<li>Metals Type: Tin Alloy</li>\n<li>Style: <strong>Trendy</strong>\n</li>\n</ul>",
      "published_at": "2018-03-09T11:21:39-05:00",
      "created_at": "2018-03-09T11:21:39-05:00",
      "updated_at": "2018-03-11T08:37:45-04:00",
      "vendor": "Anime VS Heroes",
      "product_type": "Bracelet",
      "tags": [
        "Black Panther"
      ],
      "variants": [
        {
          "id": 7239514587184,
          "title": "Golden / 19cm",
          "option1": "Golden",
          "option2": "19cm",
          "option3": null,
          "sku": "13110513-golden-leopard-19cm",
          "requires_shipping": true,
          "taxable": false,
          "featured_image": {
            "id": 2114941255728,
            "product_id": 568633786416,
            "position": 1,
            "created_at": "2018-03-09T11:21:50-05:00",
            "updated_at": "2018-03-09T11:39:43-05:00",
            "alt": null,
            "width": 640,
            "height": 640,
            "src": "https://cdn.shopify.com/s/files/1/2220/5901/products/product-image-546261907.jpg?v=1520613583",
            "variant_ids": [
              7239514587184
            ]
          },
          "available": true,
          "price": "7.99",
          "grams": 0,
          "compare_at_price": "12.99",
          "position": 1,
          "product_id": 568633786416,
          "created_at": "2018-03-09T11:21:40-05:00",
          "updated_at": "2018-03-11T08:37:45-04:00"
        },
        {
          "id": 7239514619952,
          "title": "Silver / 19cm",
          "option1": "Silver",
          "option2": "19cm",
          "option3": null,
          "sku": "13110513-silver-leopard-19cm",
          "requires_shipping": true,
          "taxable": false,
          "featured_image": {
            "id": 2114940567600,
            "product_id": 568633786416,
            "position": 2,
            "created_at": "2018-03-09T11:21:43-05:00",
            "updated_at": "2018-03-09T11:39:43-05:00",
            "alt": null,
            "width": 640,
            "height": 640,
            "src": "https://cdn.shopify.com/s/files/1/2220/5901/products/product-image-546261908.jpg?v=1520613583",
            "variant_ids": [
              7239514619952
            ]
          },
          "available": true,
          "price": "7.99",
          "grams": 0,
          "compare_at_price": "12.99",
          "position": 2,
          "product_id": 568633786416,
          "created_at": "2018-03-09T11:21:40-05:00",
          "updated_at": "2018-03-09T21:22:46-05:00"
        }
      ],
      "images": [
        {
          "id": 2114941255728,
          "created_at": "2018-03-09T11:21:50-05:00",
          "position": 1,
          "updated_at": "2018-03-09T11:39:43-05:00",
          "product_id": 568633786416,
          "variant_ids": [
            7239514587184
          ],
          "src": "https://cdn.shopify.com/s/files/1/2220/5901/products/product-image-546261907.jpg?v=1520613583",
          "width": 640,
          "height": 640
        },
        {
          "id": 2114940567600,
          "created_at": "2018-03-09T11:21:43-05:00",
          "position": 2,
          "updated_at": "2018-03-09T11:39:43-05:00",
          "product_id": 568633786416,
          "variant_ids": [
            7239514619952
          ],
          "src": "https://cdn.shopify.com/s/files/1/2220/5901/products/product-image-546261908.jpg?v=1520613583",
          "width": 640,
          "height": 640
        }
      ],
      "options": [
        {
          "name": "Color",
          "position": 1,
          "values": [
            "Golden",
            "Silver"
          ]
        },
        {
          "name": "Length",
          "position": 2,
          "values": [
            "19cm"
          ]
        }
      ]
    }
  ]
}

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.