JSONResult为String [英] JSONResult to String
本文介绍了JSONResult为String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 JsonResult
这是工作的罚款,并从一些POCO的返回JSON。我想了JSON作为保存在DB的字符串。
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.
任何帮助是AP preciated。
Any help is appreciated.
推荐答案
您正在寻找的<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx\"><$c$c>JavaScriptSerializer$c$c>类的,这是由JsonResult内部使用
You're looking for the JavaScriptSerializer
class, which is used internally by JsonResult:
string json = new JavaScriptSerializer().Serialize(jsonResult.Data);
这篇关于JSONResult为String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文