我在数据库中有一个存储 json 字符串的字段,我希望当我以 json 结果返回它时,该字段将作为 json 原始数据返回,而不是用引号作为字符串扭曲。
更新 1(更多信息):
如果您查看图像字段,它包含一个原始 json 字符串值
,但在使用 JsonResult 对其进行序列化后,它会被引号扭曲,因为它是一种字符串,我如何告诉序列化程序将图像字段视为原始 json 数据?
var db = new ModelsContainer();
var res = db.Images.OrderByDescending(i=>i.DateCreated).Skip(skip).Take(take).Select( i => new {
id = i.Id,
dateCreated = i.DateCreated,
images = i.Images ,
user = new {
id = i.User.Id,
facebookId = i.User.FacebookId,
displayName = i.User.DisplayName
},
tags = i.Tags.Select( t => t.Value )
}).ToList();
return Json(res, JsonRequestBehavior.AllowGet);
[
{
"id":"5c528e88-f3a7-4b30-9746-980867325fd1",
"dateCreated":"\/Date(1364381593000)\/",
"images":"[{\"source\":\"http://localhost:9242/images/f4956702/6d34/42db/b28a/397d0eaf3097.jpg\",\"width\":237,\"height\":237},{\"source\":\"http://localhost:9242/images/87d47041/1522/4d10/9325/105851aae259.jpg\",\"width\":633,\"height\":633},{\"source\":\"http://localhost:9242/images/2a639272/9067/42fb/83ee/e88f0a0878f8.jpg\",\"width\":547,\"height\":547},{\"source\":\"http://localhost:9242/images/37caa7b2/e183/4efc/96eb/487e556501b2.jpg\",\"width\":1024,\"height\":1024}]",
"user":{"id":"ea39616d-6ff9-424b-b99b-7bee53e674bb","facebookId":"608215901","displayName":"Yonathan Garti"},
"tags":["test","test","test"]
},
...
]