JSONResult 转字符串 [英] JSONResult to String
本文介绍了JSONResult 转字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 JsonResult
工作正常,并从一些 POCO 返回 JSON.我想将 JSON 保存为数据库中的字符串.
I have a JsonResult
that is working fine, and returning JSON from some POCO's. I want to save the JSON as a string in a DB.
public JsonResult GetJSON()
{
JsonResult json = new JsonResult
{
Data = GetSomPocos()
};
return json;
}
我需要审核响应,所以我想将 json
保存到数据库中.我找不到将 JSON 作为字符串获取的方法.
I need to audit the response, so I want to save the json
into a DB. I am having trouble finding a way to get the JSON as a string.
感谢任何帮助.
推荐答案
您正在寻找 JavaScriptSerializer
类,由 JsonResult 内部使用:
You're looking for the JavaScriptSerializer
class, which is used internally by JsonResult:
string json = new JavaScriptSerializer().Serialize(jsonResult.Data);
这篇关于JSONResult 转字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文