沫上桑 2019-03-14 17:13 采纳率: 0%
浏览 1100
已结题

java 遍历无须json 字符串 获取 节点目录及值数据

{
COSLoginReq = {
1 = [{
index = 1.0,
bytes = [0x8] 3132303030353036,
bytesInfo = [(0, 1), (1, 1), (2, 8 L)],
name = _szAccountID,
value = 12000506
}]
8 = [{
index = 8.0,
bytes = [0x33] 0 A02413112024131180120002A203836...,
bytesInfo = [(63 L, 1), (64 L, 1), (65 L, 51 L)],
name = GlogData,
value = {
GlogData = {
1 = [{
index = 1.0,
bytes = [0x2] 4131,
bytesInfo = [(0, 1), (1, 1), (2, 2 L)],
name = _szChannel,
value = A1
}],
3 = [{
index = 3.0,
bytes = [0x1] 01,
bytesInfo = [(8 L, 1), (9 L, 1)],
name = _nPlatForm,
value = 0x00000001(1 / 1)
}],
2 = [{
index = 2.0,
bytes = [0x2] 4131,
bytesInfo = [(4 L, 1), (5 L, 1), (6 L, 2 L)],
name = _szSubChannel,
value = A1
}],
5 = [{
index = 5.0,
bytes = [0x20] 3836383133333033383734303233392 D...,
bytesInfo = [(12 L, 1), (13 L, 1), (14 L, 32 L)],
name = _strDeviceID,
value = 868133038740239 - ebd24632ac91bfc1
}],
4 = [{
index = 4.0,
bytes = [0x1] 00,
bytesInfo = [(10 L, 1), (11 L, 1)],
name = _bIsSimulator,
value = 0x00000000(0 / 0)
}],
6 = [{
index = 6.0,
bytes = [0x3] 313932,
bytesInfo = [(46 L, 1), (47 L, 1), (48 L, 3 L)],
name = _strMid,
value = 192
}]
}
}
}]
}
}

像这样的一个json 内容不知道的情况下要获取到所有值及值所在的各级节点
期望得到的结果 如key= COSLoginReq-1-index value = 1
其中第三层嵌套的结果期望得到的是
key= COSLoginReq-8-value-GlogData-1-index value = 1

这样的数据 有大神解惑么 我做到第三层嵌套解析就不行乐

作者:qq_25845665
来源:CSDN
原文:https://blog.csdn.net/qq_25845665/article/details/88556876
版权声明:本文为博主原创文章,转载请附上博文链接!

  • 写回答

2条回答 默认 最新

  • mitcub 2019-03-14 17:20
    关注

    用gson java建立对应的实体就可以啦,你把json 拷贝到http://www.bejson.com/json2javapojo/new/ 直接生成对应的类

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘