如何从Java中的ResponseEntity <string>中删除重复的对象

时间:2019-01-09 14:58:50

标签: java json

我有一个包含json字符串的ResponseEntity。我需要从该字符串中读取值并删除重复的对象。

Json String:

{
    "AccountList": {
        "Accounts": [
            {
                "Id": 1466010,
                "IdSpecified": true,
                "Number": "04F200S",
                "ClientId": 82694,
                "ClientIdSpecified": true,
                "ClientNumber": "04F200",
                "Name": "name 04F200S",
                "RepresentativeId": "RM00",
                "Currency": "CAD",
                "Balance": 169.03,
                "BalanceSpecified": true,
                "TotalValue": 169.03,
                "TotalValueSpecified": true,
                "MarketValueSpecified": false,
                "Type": "S",
                "AccountTypeFr": "REER autogéré",
                "AccountTypeEn": "Self Directed RRSP",
                "InceptionDate": "2013-06-10T00:00:00-04:00",
                "InceptionDateSpecified": true,
                "ClassType": "ACCOUNT",
                "ClassDescription": "Real Account",
                "StatusSpecified": false,
                "CurrencyPerformanceListSpecified": false,
                "PerformancePeriodListSpecified": false,
                "AssetAllocationSpecified": false,
                "SecurityListSpecified": false
            }
        ]
    },
    "CurrencyPerformanceList": {
        "CurrencyPerformances": [
            {
                "Currency": "CAD",
                "PerformanceList": {
                    "PerformanceTypeSpecified": false,
                    "KeySpecified": false,
                    "KeyIdSpecified": false,
                    "Performances": [
                        {
                            "StartDate": "2014-01-15T00:00:00",
                            "StartDateSpecified": true,
                            "EndDate": "2014-06-01T00:00:00",
                            "EndDateSpecified": true,
                            "Currency": "CAD",
                            "ROI": 5.503494,
                            "ROISpecified": true,
                            "NonAnnualizedROI": 5.503494,
                            "NonAnnualizedROISpecified": true,
                            "StartingValue": 97878.26,
                            "StartingValueSpecified": true,
                            "EndingValue": 103337.68,
                            "EndingValueSpecified": true,
                            "Inflows": 70.5,
                            "InflowsSpecified": true,
                            "Outflows": 0,
                            "OutflowsSpecified": true,
                            "Revenues": 1667.19999936,
                            "RevenuesSpecified": true,
                            "StandardDeviationSpecified": false,
                            "NonAnnualizedStandardDeviationSpecified": false,
                            "SharpeIndexSpecified": false,
                            "NonAnnualizedSharpeIndexSpecified": false
                        }
                    ],
                    "PerformancesSpecified": true
                }
            }
        ]
    }
}

我正在尝试做的事情:

performance = objectMapper
                            .readValue(performanceQueryService.getAggregatedAccountPerformances(req).getBody(), PeriodData.class)
                            .getCurrencyPerformanceList();

期间数据。类:

public class PeriodData {

    private List<String> accountList;
    private CurrencyPerformances CurrencyPerformanceList;

    public List<String> getAccountList() {
        return accountList;
    }
    public void setAccountList(List<String> accountList) {
        this.accountList = accountList;
    }
    public CurrencyPerformances getCurrencyPerformanceList() {
        return CurrencyPerformanceList;
    }
    public void setCurrencyPerformanceList(CurrencyPerformances currencyPerformanceList) {
        CurrencyPerformanceList = currencyPerformanceList;
    }

}

在读取值时,请让我知道我在哪里做错了。它只是将变量性能设置为null。谢谢!

0 个答案:

没有答案