Foxtable(狐表)用户栏目专家坐堂 → [求助]如何判断JToken的类型?


  共有1003人关注过本帖树形打印复制链接

主题:[求助]如何判断JToken的类型?

帅哥哟,离线,有人找我吗?
zyl19810322
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:110 积分:1545 威望:0 精华:0 注册:2017/8/2 21:39:00
[求助]如何判断JToken的类型?  发帖心情 Post By:2024/9/13 11:46:00 [只看该作者]

Dim json As String = "{""name"":""John Doe"",""age"":30,""isEmployed"":true,""skills"":[""C#"",""VB.NET"",""SQL""],""address"":{""street"":""123 Main St"",""city"":""Anytown"",""zip"":""12345""}}"
Dim jo As JObject = JObject.Parse(json)
For Each it As JToken In jo.Children 
        Output.Show(it.Type)
Next
以上代码输出全部为4,明明有JTokenType.Object,JTokenType.Array,JTokenType.Property

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110443 积分:562081 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2024/9/13 12:02:00 [只看该作者]

Dim json As String = "{""name"":""John Doe"",""age"":30,""isEmployed"":true,""skills"":[""C#"",""VB.NET"",""SQL""],""address"":{""street"":""123 Main St"",""city"":""Anytown"",""zip"":""12345""}}"
Dim jo As JObject = JObject.Parse(json)
For Each it As Object In jo 
    Output.Show(it.value.Type)
Next

For Each item As JTokenType In [Enum].GetValues(GetType(JTokenType))
    Output.Show(item & "-" & item.Tostring())
Next

 回到顶部
帅哥哟,离线,有人找我吗?
zyl19810322
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:110 积分:1545 威望:0 精华:0 注册:2017/8/2 21:39:00
  发帖心情 Post By:2024/9/13 12:06:00 [只看该作者]

谢谢


 回到顶部