Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.1k views
in Technique[技术] by (71.8m points)

递归结构json取出所有id最大值

怎么获取所有的value值,并取出最大值呢
数据引用递归结构的json取指定的值?

[
  {
    "label": "上海",
    "value": 310000,
    "children": [
      {
        "label": "上海",
        "value": 310100,
        "children": [
          {
            "label": "金山",
            "value": 310116,
            "children": [
              {
                "label": "测试123123",
                "value": 133
              }
            ]
          },
          {
            "label": "黄浦",
            "value": 310101,
            "children": [
              {
                "label": "测试播放系统",
                "value": 123
              },
              {
                "label": "DreamFitness",
                "value": 130
              }
            ]
          },
          {
            "label": "闵行",
            "value": 310112,
            "children": [
              {
                "label": "测试1",
                "value": 128
              },
              {
                "label": "纽绍客",
                "value": 129
              }
            ]
          },
          {
            "label": "浦东",
            "value": 310115,
            "children": [
              {
                "label": "兼容场馆",
                "value": 125
              }
            ]
          },
          {
            "label": "徐汇",
            "value": 310104,
            "children": [
              {
                "label": "美奂旗舰店",
                "value": 122
              },
              {
                "label": "开发测试",
                "value": 124
              },
              {
                "label": "欣欣向荣",
                "value": 126
              },
              {
                "label": "魏叶的场馆",
                "value": 127
              },
              {
                "label": "测试",
                "value": 131
              },
              {
                "label": "测试2",
                "value": 132
              }
            ]
          }
        ]
      }
    ]
  }
]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

你得问问后端老哥
省市区这等类型的区域数据存储,现在基本都是单条记录,分表或单表存储的
也就是说接口返回给你,是原本一维的数据做了group分组的

不方便的话,自己顶层排个序,取末尾的最深层最大值吧


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...