POST json dictionary

后端 未结 10 862
猫巷女王i
猫巷女王i 2020-11-27 05:52

I\'m trying the following : A model with a dictionary inside send it on the first ajax request then take the result serialize it again and send it back to the controller.

10条回答
  •  -上瘾入骨i
    2020-11-27 06:41

    Using ASP.NET 5 and MVC 6 straight out of the box I'm doing this:

    jSON:

    {
        "Name": "somename",
        "D": {
            "a": "b",
            "b": "c",
            "c": "d"
        }
    }
    

    Controller:

    [HttpPost]
    public void Post([FromBody]Dictionary dictionary)
    {
    }
    

    This is what shows up when it comes through (Name and D are the keys):

提交回复
热议问题