How to create json array as a string with Object list

  • Thread starter Thread starter Learning Rocks
  • Start date Start date
L

Learning Rocks

Guest
Hello Everyone,

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

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

Continue reading...
 
Back
Top