从json结构获取特定值 [英] Get a specific value from a json structure
本文介绍了从json结构获取特定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个json:
{
"unashamedohio":
{
"id": 107537,
"name": "UnashamedOhio",
"profileIconId": 785,
"revisionDate": 1439997758000,
"summonerLevel": 30
}
}
我想获取名为summonerLevel
的字段.
我尝试将json转换为字符串,然后搜索summonerLevel
,但我知道此解决方案不可行.
I have tried to convert this json to a string and then search for summonerLevel
, but I know that this solution is not okay.
我正在使用Json.NET.
I'm using Json.NET.
推荐答案
您可以使用dynamic
关键字
dynamic obj = JsonConvert.DeserializeObject(json);
Console.WriteLine(obj.unashamedohio.summonerLevel);
这篇关于从json结构获取特定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文