过滤Json响应

时间:2019-05-02 09:53:28

标签: json filtering

我有返回XML的API,我正在将结果映射到可以正常工作的自定义模型,并将结果转换为Json响应。
我需要根据规则集过滤Json响应并删除相关的响应节点。例如,如果“日期”大于5年或“类型”:“ F”,则需要删除“响应”节点,而仅保留相关的响应节点。

全结果:

我需要删除它:

                    "Info": {
                        "Number": "1",
                        "Date": "2013-03-01"
                    },
                    "CInfo": {
                        "Id": "1111",
                        "Type": "F"
                    },
                    "Subject": {
                        "Role": "CT",
                        "SNumber": "1"

                    },


                }
            }```




ant return this:


```{
    "Message": "True",
    "APIResponse": {
        "SearchedSubject": {
            "RequestSubject": {
                "Title": "",
                "Forename": "Jo",
                "Surname": "Blog",
                "DateOfBirth": "19720804T00:00:00",
                "Gender": "",
            },
            "RequestAddress": {
                "HouseNr": "171",
                "Street1": "Any Road",
                "Street2": "",
                "City": "London",
                "PostCode": "E177BR",
                "Country": "London"
            }
        },
        "Responses": [

            {
                "Response": {
                    "Info": {
                        "Number": "2",
                        "Date": "2017-03-22"
                    },
                    "CInfo": {
                        "Id": "22222",
                        "Type": "L",
                    },
                    "Subject": {
                        "Role": "CT",
                        "Number": "1"
                    },


                }
            }
        ]
    }
}```

The full response is

```{ 
    "APIResponse": {
        "SearchedSubject": {
            "RequestSubject": {
                "Title": "",
                "Forename": "Jo",
                "Surname": "Blog",
                "DateOfBirth": "19720804T00:00:00",
                "Gender": "",
            },
            "RequestAddress": {
                "HouseNr": "171",
                "Street1": "Any Road",
                "Street2": "",
                "City": "London",
                "PostCode": "E177BR",
                "Country": "London"
            }
        },
        "Responses": [
            {
                "Response": {
                    "Info": {
                        "Number": "1",
                        "Date": "2013-03-01"
                    },
                    "CInfo": {
                        "Id": "1111",
                        "Type": "F"
                    },
                    "Subject": {
                        "Role": "CT",
                        "SNumber": "1"

                    }, 
                }
            },
            {
                "Response": {
                    "Info": {
                        "Number": "2",
                        "Date": "2017-03-22"
                    },
                    "CInfo": {
                        "Id": "22222",
                        "Type": "L",
                    },
                    "Subject": {
                        "Role": "CT",
                        "Number": "1"
                    },
                }
            }
        ]
    }
}```

0 个答案:

没有答案