当前位置:优学网  >  在线题库

Java获取唯一字段的值总和

发表时间:2022-07-26 00:33:06 阅读:115

在java中,如何从java中的JSON对象中获取唯一location_id字段的maxRegistration和current_registration字段之和.我说sum是因为location_id可能在json中重复.我刚接触java a,这对我来说相当复杂.

[
  {
    "date": "2022-06-29",
    "registrationDetails": {
      "registration": {
        "maxRegistration": 10,
        "restriction": "perBooking"
      }
    },
    "location_id": "1111",
    "book_id": "abcd",
    "current_registration": 4,

  },
  {
    "date": "2022-06-29",
    "registrationDetails": {
      "registration": {
        "maxRegistration": 15,
        "restriction": "perBooking"
      }
    },
    "location_id": "1111",
    "book_id": "efgh",
    "current_registration": 7,

  },
  {
    "date": "2022-06-29",
    "registrationDetails": {
      "registration": {
        "maxRegistration": 10,
        "restriction": "perBooking"
      }
    },
    "location_id": "3673",
    "book_id": "1112",
    "current_registration": 8,

  }

]
🎖️ 优质答案
相关问题