0

I have tried some ways to get my product details from json array.can any one help me to do in c#, Just i have added my api response below. from that response i need to extract product details to list. thanks in advance.

API Response: { "Status": "success", "Result": [ { "order_id": "SG20011000007", "order_amount": "2970", "delivery_api_status": "Scheduled", "oid": "20011", "buyer": "guest", "shipping_address": "{"gt_data":"2970","grand1":"2970","firstname":"MANIMARAN S","lastname":null,"address1":"408868 Geylang","address2":"BBBB","zip":"408868","phone":"123","email":"svenkatesh.unipro@gmail.com","floor_no":"123","unit_no":"123","country":"Singapore","state":null,"cities":null,"short_country":"SG"}", "vat": null, "tax_method": "default", "vat_percent": "", "shipping": "0", "payment_type": "cash_on_delivery", "payment_status": "[{"admin":"","status":"paid"}]", "discount": null, "sale_datetime": "1613360073", "delivery_status": "[{"admin":"","status":"delivered","delivery_time":""}]", "created_datetime": "2021-02-15 09:04:33", "order_type": "shopping", "type": "delivery", "product_details": [ "{"8d7c30cf7b10b49f854c2a295a5c9413":{"id":"24465","qty":1,"option":"{\"color\":{\"title\":\"Color\",\"value\":null}}","price":1485,"name":"Headset","discount_type":"","after_coupon":0,"shipping":null,"tax":null,"image":"http:\/\/storesmartstore.com\/uni-inclusive\/uploads\/product_image\/product_24465_1_thumb.jpg","coupon":"","rowid":"8d7c30cf7b10b49f854c2a295a5c9413","subtotal":1485,"tax_percent":"0","tax_type":"percent","tax_method":"default"}}", "{"0608bbe8fc09e0880e7d866d513c7c53":{"id":"24466","qty":1,"option":"{\"color\":{\"title\":\"Color\",\"value\":null}}","price":1485,"name":"Mobile","discount_type":"","after_coupon":0,"shipping":null,"tax":null,"image":"http:\/\/storesmartstore.com\/uni-inclusive\/uploads\/product_image\/product_24466_1_thumb.jpg","coupon":"","rowid":"0608bbe8fc09e0880e7d866d513c7c53","subtotal":1485,"tax_percent":"0","tax_type":"percent","tax_method":"default"}}" ] } ] }

  • You can find tons of resources about how to do JSON deserialization. You can start with creating C# classes for your JSON by using https://json2csharp.com/ and use NewtonSoft.Json to deserialize jSON to c# class objects. – Chetan Feb 16 '21 at 03:06
  • HI Ranpariya, thanks for the response, yes correct i am also use that same json2csharp.com for convert json to c#, but now the problem is when i am try to convert, the product details list class not created,bcz u see the above example, it having the unique value without label. that's why i have some trouble. if have any link then please let me know. thanks – Venkatesh S Feb 16 '21 at 03:35
  • Use Edit | Paste Special | Paste JSON as Classes in Visual Studio. – ProgrammingLlama Feb 16 '21 at 03:47

0 Answers0