Skip to main content
Post Closed as "Duplicate" by nawfal, Tanner, Sriram Sakthivel c#
edited tags
Source Link
Tejas Vora
  • 548
  • 9
  • 19

I would like to convert following Json Array to .net list wrapper. Not sure how ca I do that.

Json Array:

[{"Name" : "SomeName1", "Age" : "20" },{ "Name" : "SomeName2", "Age" : "21"}]

My class is:

public class Person
{
    public string Name;
    public string Age;
}

If I use List<Person> as my conversion type then everything works fine.

But what I would like to do is to convert above array to following class's object;

public class PersonList
{
    public string somefield;
    public List<Person> PersonList;
}

I am not able to convert my array to List wrapper object. How can I do that?

I do not have control over conversion method. I am using RestSharp library to execute my web request. When I call execute method, I would like to pass PersionList type for conversion and not List

I would like to convert following Json Array to .net list wrapper. Not sure how ca I do that.

Json Array:

[{"Name" : "SomeName1", "Age" : "20" },{ "Name" : "SomeName2", "Age" : "21"}]

My class is:

public class Person
{
    public string Name;
    public string Age;
}

If I use List<Person> as my conversion type then everything works fine.

But what I would like to do is to convert above array to following class's object;

public class PersonList
{
    public string somefield;
    public List<Person> PersonList;
}

I am not able to convert my array to List wrapper object. How can I do that?

I would like to convert following Json Array to .net list wrapper. Not sure how ca I do that.

Json Array:

[{"Name" : "SomeName1", "Age" : "20" },{ "Name" : "SomeName2", "Age" : "21"}]

My class is:

public class Person
{
    public string Name;
    public string Age;
}

If I use List<Person> as my conversion type then everything works fine.

But what I would like to do is to convert above array to following class's object;

public class PersonList
{
    public string somefield;
    public List<Person> PersonList;
}

I am not able to convert my array to List wrapper object. How can I do that?

I do not have control over conversion method. I am using RestSharp library to execute my web request. When I call execute method, I would like to pass PersionList type for conversion and not List

edited tags
Link
Tejas Vora
  • 548
  • 9
  • 19
Source Link
Tejas Vora
  • 548
  • 9
  • 19

Convert Json Array to .Net List wrapper

I would like to convert following Json Array to .net list wrapper. Not sure how ca I do that.

Json Array:

[{"Name" : "SomeName1", "Age" : "20" },{ "Name" : "SomeName2", "Age" : "21"}]

My class is:

public class Person
{
    public string Name;
    public string Age;
}

If I use List<Person> as my conversion type then everything works fine.

But what I would like to do is to convert above array to following class's object;

public class PersonList
{
    public string somefield;
    public List<Person> PersonList;
}

I am not able to convert my array to List wrapper object. How can I do that?