Read JSON and Pass property value to Method in ASP.Net MVC

on Feb 02, 2021 03:27 AM


I have one joson object likr blelow

{ "Items":[{"Id":12,"Name":"s"},{"Id":23,"Name":"b"}] }

my requirement is that how to pass Id to method from Items Object

could you please help me 

public void GetNumber(){



Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Feb 02, 2021 03:53 AM

Hi mahesh213,

Refer below code.

public void GetNumber(int id)


public class Details

    public Item[] Items { get; set; }
public class Item
    public int Id { get; set; }
    public string Name { get; set; }

Then get it like below.

string json = "Your Json string";
Details detail = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<Details>(json);
foreach (Item item in detail.Items)