Reputation: 2395
What I'm trying to do is send some JSON to a .net webserver the JSON looks like this.
var mydata =
{
"filters": {
"game": -1,
"mediatype": -1,
"location": -1,
"contributor": -1
},
"tags": [1,2,3,4],
"search": "",
"startindex": 6,
"fetchcount": 12
}
From what I've been reading, Web API will automatically turn this JSON in to a strongly typed .net object. I'm still getting my head round how the structure of these objects work. Can any one show me What the .net object should look so that this JSON object and be automatically converted.
I plan to do something like this in my controller
public int FilterLoad([FromBody]mydata> test)
Upvotes: 0
Views: 884
Reputation: 754
To get an idea you can use http://json2csharp.com/
For this json it produces this:
public class Filters
{
public int game { get; set; }
public int mediatype { get; set; }
public int location { get; set; }
public int contributor { get; set; }
}
public class RootObject
{
public Filters filters { get; set; }
public List<int> tags { get; set; }
public string search { get; set; }
public int startindex { get; set; }
public int fetchcount { get; set; }
}
Upvotes: 2