序列化JSON字符串动态对象 [英] Serialize JSON String To Dynamic Object

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

问题描述

OK,请原谅我,如果我有错的术语。我试图做到以下几点。

OK, please forgive me if I have the terminology wrong. I am attempting to do the following.


  1. 从URL获取JSON字符串

  2. 解析说串入一个对象。

通常对我来说这将是非常容易的。通常情况下,JSON对象是静态的名字。

Normally for me this would be very easy. Usually the JSON objects are static names.

当出现问题是,子JSON对象而异人到人。如果你改变你的库存也将发生变化。

Where the problem arises is that the sub json objects vary person to person. They will also change if you change your inventory.

现在,我需要能够把这个变成一个对象,并对其进行查询(不一定是LINQ,但拉数据随意)。没有任何人有任何信息?我试图创造一个动态对象(如下所示反序列化JSON到C#动态对象? ),但它并没有为我工作。

Now, I need to be able to put this into an object, and query it (not necessarily linq, but pull data at will). Does anyone have any information? I attempted at creating a dynamic object (as shown here Deserialize JSON into C# dynamic object?) but it did not work for me.

请问该链接实际上是适合我的目的,我才刚刚实现它正确?

Would that link actually suit my purposes, and did I just implement it incorrectly?

下面是一个什么样的JSON看起来像一个转储: http://chopapp.com/ #ro46jfay

Here is a dump of what the JSON looks like: http://chopapp.com/#ro46jfay

感谢您的一切帮助。

推荐答案

Newtonsoft Json.net 支持创建从JSON动态对象。

Newtonsoft Json.net supports creating dynamic objects from json.

var obj = JsonConvert.DeserializeObject<dynamic>(json); 

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

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