I have such JSON string:
'{"1":[1,3,5],"2":[2,5,6],"3":[5,6,8]}'
I want to send it to the Web Api Controller without changing using ajax request:
$.ajax({
type: "POST",
url: "Api/Serialize/Dict",
data: JSON.stringify(sendedData),
dataType: "json"
});
In Web Api I have such method:
[HttpPost]
public object Dict(Dictionary<int, List<int>> sendedData)
{
//code goes here
return null;
}
And always sendedData == null.
Another words: I don't know how to deserialize JSON into (Dictionary<int, List<int>>
.
Thank you for answer.
Try this
You can send the data like this:
Image of the function in the controller: Dict
specify the content type parameter when performing ajax call, dataType is for return result:
Try it:
Try using:
This works when the sent data doesn't have quotes around the indices:
Also make sure that you send an object in the Javascript: