schoolInformation
是相同的
classInformation.teacherPercentage
和classInformation.teachInfo.id
classInformation.studentPercentage
,
classInformation.studentInfo.id
是相同的
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"
}
}
]
}
]
}