mardi 5 mai 2015

Deserialize JSON with Numeric Rows

I am trying to deserialize some JSON into a list using JSON.NET; however, there is a number in the way:

Here is the JSON:

"payment_info": {
    "fb_id": "",
    "order_items": {
      "0": {
        "product_id": "4534",
        "type": "product",
        "shipping_cost_per_item": "1.00",
        "quantity": "3",
        "price_each": "10.00",
        "price_total": "30.00"
      }
    },

Here is my class:

    public class OrderItem
    {
        public string product_id { get; set; }
        public string type { get; set; }
        public string shipping_cost_per_item { get; set; }
        public string quantity { get; set; }
        public string price_each { get; set; }
        public string price_total { get; set; }
    }

    public class OrderItems
    {
        public List<OrderItem> Items { get; set; }
    }

How do I tell the converter to ignore the 0? There will be a 1,2,3 for each order item.

Aucun commentaire:

Enregistrer un commentaire