Return JSON using C# like PHP json_encode

前端 未结 4 789
醉酒成梦
醉酒成梦 2020-12-18 03:43

In PHP to return some JSON I would do:

return json_encode(array(\'param1\'=>\'data1\',\'param2\'=>\'data2\'));

how do I do the equivalent

4条回答
  •  囚心锁ツ
    2020-12-18 04:03

    The simplest way it may be like this:

    public JsonResult GetData()
    {      
        var myList = new List();
    
        //populate the list
    
        return Json(myList);
    }
    

提交回复
热议问题