locked
How to create json array string with Object RRS feed

  • Question

  • User339833461 posted

    Hello Everyone, 

    I have below code. how to write this object list into json array string using c#.

    Thanks

    List<Item> items = new List<Item>
                              {
                                 new Item { name = "test1", index = "index1", itemDetails = new ItemProperties{ItemId = "39942dg", Price = 200.00 } },
                                 new Item { name = "test2", index = "index2", itemDetails = new ItemProperties{ItemId = "67942dg", Price = 1000.00 } }
                              };
    
    public class Item
        {
            public string name { get; set; }
            public string index { get; set; }
            public ItemProperties itemDetails { get; set; }
        }
    
        public class RootObject
        {
            public List<Item> items { get; set; }
        }
        public class ItemProperties
        {
            public string ItemId { get; set; }
            public double Price { get; set; }
        }

    Thanks

    Thursday, April 23, 2020 12:57 PM

Answers

All replies