Foxtable(狐表)用户栏目专家坐堂 → 解析JSON如何统计数据


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

主题:解析JSON如何统计数据

帅哥,在线噢!
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:109469 积分:557007 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2023/4/10 20:09:00 [显示全部帖子]

dim json as string = "上面的json....."
Dim ja As JArray = JArray.Parse(json)
dim dict as new dictionary(of string,integer)
Dim jo As JObject
For i As Integer = 0 To ja.Count - 1
   
jo =ja(i)
Dim ja2 As JArray = jo("因数")
For j As Integer = 0 To ja2.Count - 1
   if 
dict.containskey(ja2(j).tostring) then
dict(ja2(j).tostring) += cint(jo("数量"))
else
dict.add(ja2(j).tostring,cint(jo("数量")))
end if
Next
Next
For Each k As string In dict.Keys '显示所有键及其对应的值
    
Output.Show(K & ":" & dict(k))
Next

 回到顶部