0

I have the following JSON string -

"[
{\"id\":0,\"picurl\":\"/pics/kuku/Picture 001.jpg\"},
{\"id\":1,\"picurl\":\"/pics/kuku/Picture 002.jpg\"},
{\"id\":2,\"picurl\":\"/pics/kuku/Picture 003.jpg\"},
{\"id\":3,\"picurl\":\"/pics/kuku/Picture 004.jpg\"},
{\"id\":4,\"picurl\":\"/pics/kuku/Picture 005.jpg\"},
{\"id\":5,\"picurl\":\"/pics/kuku/Picture 006.jpg\"},
{\"id\":6,\"picurl\":\"\"}
]"

recieved from client.

How can I parse it to a List of picITEM ???

public  class picITEM
{
    string id {get;set;}
    string picurl { get; set; }

}
Jenish Rabadiya
  • 6,708
  • 6
  • 33
  • 62
Shai
  • 355
  • 2
  • 5
  • 18

2 Answers2

0

use this

 IList<picITEM> persons = new JavaScriptSerializer().Deserialize<IList<picITEM>>(jsonString);
Abbas Galiyakotwala
  • 2,949
  • 4
  • 19
  • 34
0

Use Json.Net nugget package. Include that package in your project and write below code:

List<picITEM> items = JsonConvert.DeserializeObject<Product>(yourvaribaleofjson);

I took the list as your question state that you are getting multiple json values.

JSON.NET nugget url

Please let me know if you face any trouble.

Community
  • 1
  • 1
Priyank Sheth
  • 2,352
  • 19
  • 32