JSON反序列化对象成 [英] Deserializing JSON into Object

查看:117
本文介绍了JSON反序列化对象成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我反序列化JSON字符串转换为对象。我不能使用词典<字符串,字符串> 由于JSON里面很复杂。我知道关于词典<字符串,动态> ,但我在.NET 3.5框架,所以我不能使用动态

I'm deserializing a JSON string into an object. I can't use a Dictionary<string, string> because the JSON inside is complex. I know about the Dictionary<string, dynamic>, but I'm over the .NET 3.5 framework, so I can't use dynamic.

所以,我在这里结束了:

So I ended up here:

object json = new JavaScriptSerializer().Deserialize<object>("myjson");



不过,我看不出有什么方法来访问 JSON 没有反映。任何提示?

But I see no way to access json without reflection. Any tips?

推荐答案

我会用的 ServiceStack.Text 并使用JsonObject.Parse解析它。

I would use ServiceStack.Text and parse it using JsonObject.Parse.

然后,你必须是易于读取数据的字典。

Then you have a Dictionary of data that is easy to read.

ServiceStack为更快更好比Json.NET。

ServiceStack is faster and better than Json.NET.

这篇关于JSON反序列化对象成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆