我正在尝试弄清楚如何从以下条件匹配以下条件:

问题描述 投票:0回答:0
schoolInformation

是相同的

classInformation.teacherPercentage

classInformation.teachInfo.id
  • classInformation.studentPercentage
    classInformation.studentInfo.id
    是相同的
  • json:
    classInformation.studentInfo.style
    输出:
    classInformation.studentInfo.graduationYear
    data类:
  • { "schoolInfomration": [ { "classInformation": [ { "studentPercentage": 50, "studentInfo": { "id": 4, "style": 3, "graduationYear": 2028 } }, { "teacherPercentage": 50, "teacherInfo": { "id": "10019", "name" : "test2" } } ] }, { "classInformation": [ { "studentPercentage": 50, "studentInfo": { "id": 4, "style": 3, "graduationYear": 2028 } }, { "teacherPercentage": 50, "teacherInfo": { "id": "10019", "name" : "test1" } } ] }, { "classInformation": [ { "studentPercentage": 50, "studentInfo": { "id": 4, "style": 3, "graduationYear": 2023 } }, { "teacherPercentage": 50, "teacherInfo": { "id": "10018", "name": "test3" } } ] } ] }

如果您想在对JSON进行估算之前删除重复项,则可以考虑库,因为它提供了几种操纵JSON节点的方法。您的代码将是这样的:

{ "schoolInfomration": [ { "classInformation": [ { "studentPercentage": 50, "studentInfo": { "id": 4, "style": 3, "graduationYear": 2028 } }, { "teacherPercentage": 50, "teacherInfo": { "id": "10019", "name" : "test2" } } ] }, { "classInformation": [ { "studentPercentage": 50, "studentInfo": { "id": 4, "style": 3, "graduationYear": 2023 } }, { "teacherPercentage": 50, "teacherInfo": { "id": "10018", "name": "test3" } } ] } ] }

	

java arrays json kotlin
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.