JSON Web Service Response:

{
  "code": "OK",
  "total": 1,
  "offset": 0,
  "items": [
    {
      "ean": "0070501152959",
      "title": "Neutrogena Moisture Wrap Daily Repair Body Lotion, 15.2 fl oz",
      "description": "15.2-ounce bottle of daily repair body lotionHelps relieve uncomfortably dry skinClinically proven to help skin retain more hydrationContains blend of moisturizers to help relieve drynessRecommended by dermatologistsContains fragrance",
      "upc": "070501152959",
      "brand": "Neutrogena Corporation",
      "model": "070501152959",
      "color": "Gold",
      "size": "Pack of 8",
      "dimension": "3.3 X 2.1 X 8.6 inches",
      "weight": "38 Pounds",
      "currency": "",
      "lowest_recorded_price": 0,
      "highest_recorded_price": 54.24,
      "images": [
        "http://ct.mywebgrocer.com/legacy/productimagesroot/DJ/1/846601.jpg",
        "http://images.prosperentcdn.com/images/250x250/images.shopko.com/get/w/245/h/245/138228_0000.jpg%3Fnotfound%3Dnotavailable",
        "http://images.shopko.com/get/w/245/h/245/138228_0000.jpg?notfound=notavailable",
        "http://images.prosperentcdn.com/images/250x250/images.shopko.com/get/w/245/h/245/138228_0000.jpg%3Fnotfound%3Dnotavailable",
        "http://images.prosperentcdn.com/images/250x250/images.shopko.com/get/w/245/h/245/138228_0000.jpg%3Fnotfound%3Dnotavailable",
        "https://target.scene7.com/is/image/Target/GUEST_5607acb5-18be-49f8-9759-b4c82542440a?wid=1000&hei=1000",
        "https://i5.walmartimages.com/asr/2b00251e-1f3e-400b-ade2-2079270dce39_1.7c37ff6d96bd69b9321b166b0bac46c8.jpeg?odnHeight=450&odnWidth=450&odnBg=ffffff",
        "http://pics1.ds-static.com/prodimg/220746/300.JPG",
        "http://img1.r10.io/PIC/49967054/0/1/250/49967054.jpg",
        "https://pics.drugstore.com/prodimg/220746/450.jpg"
      ],
      "asin": "B00G4EJKXE",
      "elid": "123671664747"
    }
  ]
}

C# JSON Parser:

            var client = new WebClient();
            var serializer = new JavaScriptSerializer();  
              
                var json = client.DownloadString("https://api.upcitemdb.com/prod/trial/lookup?upc=070501152959");

                dynamic dJson = serializer.Deserialize<object>(json);

                var items = dJson["items"];

                ProductName = items[0]["title"];
                ProductDescription = items[0]["description"];
                ProductBrand = items[0]["brand"];

                // Images
                var lstImages = items[0]["images"];

                ProductPhotoList = new List<string>();

                foreach (var image in lstImages)
                {
                    ProductPhotoList.Add(image);
                }

Last modified: April 29, 2019

Author

Comments

Write a Reply or Comment