在ASP MVC 4解析JSON文本到C#对象 [英] parse Json text to C# object in asp mvc 4
问题描述
我有一个巨大的量我想将它们保存在数据库自定义属性,我很困惑,如何将它们存储在数据库中,我想将它们存储由
I have a huge amount of customized attributes I want to save them in the DataBase, I was confused of how to store them in the database, i thought of storing them as a string separating them by
( =
=>名称,值)(;
=>属性,属性),但code为不优雅了!
(=
=> name , value) (;
=> attribute , attribute) but the code wasn't elegant at all!
所以我STAT想保存为的Json
字符串,但我无法找到一个
的Json对象解析器
so i stat thinking of saving them as Json
string but I couldn't found a
Json to object parser
,而我们只需要调用 JSON()
来解析对象JSON字符串
while we need only to call json()
to parse object to json string
有没有比使用JSON字符串更好的办法,是有提供JSON字符串解析器?
is there a better way than using json string and is there json string parser provided ?
推荐答案
很多人用 Json.net 进行序列化
var log = JsonConvert.DeserializeObject<YourObject>(logJson)
和其他方向
var logJson = JsonConvert.SerializeObject(log);
这篇关于在ASP MVC 4解析JSON文本到C#对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!