生成格式化的json

 public static ContentResult returnJson(object obj)
        {
            var content = new ContentResult()
            {
                Content = JsonConvert.SerializeObject(obj, Formatting.Indented),
                ContentType = "application/json"

            };
            return content;
        }

如:{"a":1,"b":2}

{
    "a": 1,
    "b": 2
}

posted @ 2016-12-24 19:18  小小高  阅读(176)  评论(0)    收藏  举报