Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to process the json array data in the HTTPPOST method mentioned below

[HttpPost]
        [Route("")]
        public async Task<HttpResponseMessage> UploadFile(jsonarraydata)
        {
//how to convert the json array data in objects 
            
    }


What I have tried:

Below is the json array I am passing to post request. I want to convert the array in individual objects so that i can store them in the database.
<pre>[{
  "Name": "sample string 1",
  "Owner": "abc"
}
,	
{
  "Name": "sample string 2",
  "Owner": "xyz"
},
{
  "Name": "sample string 3",
  "Owner": "ags"
},
{
  "Name": "sample string 4",
  "Owner": "sdas"
}
 ]
Posted
Updated 8-Mar-17 23:54pm

1 solution

Create a Class with the required properties

public class MyType
  {
      public string Name { get; set; }
      public string Owner { get; set; }

  }


and access it as a list.
public async Task<HttpResponseMessage> UploadFile(List<MyType> jsonarraydata )
{
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900