LocalDateTime的ObjectMapper反序列化

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

我有这个json

{
    "@class": "java.util.Collections$UnmodifiableMap",
    "settings.token.reuse-refresh-tokens": true,
    "settings.token.id-token-signature-algorithm": [
        "org.springframework.security.oauth2.jose.jws.SignatureAlgorithm",
        "RS256"
    ],
    "settings.token.access-token-time-to-live": [
        "java.time.Duration",
        7200.000000000
    ],
    "settings.token.access-token-format": {
        "@class": "org.springframework.security.oauth2.server.authorization.settings.OAuth2TokenFormat",
        "value": "self-contained"
    },
    "settings.token.refresh-token-time-to-live": [
        "java.time.Duration",
        3600.000000000
    ],
    "settings.token.authorization-code-time-to-live": [
        "java.time.Duration",
        300.000000000
    ]
}

我使用反序列化

ObjectMapper mapper = new ObjectMapper();
        Map<String, Object> mapp = mapper.readValue(json, new TypeReference<Map<String, Object>>() {
        });

但是映射器返回

"settings.token.authorization-code-time-to-live": [
        "java.time.Duration",
        300.000000000
    ]

我怎样才能删除

java.time.Duration

并留在

settings.token.authorization-code-time-to-live": 300.000000000
spring-security jackson-databind objectmapper
© www.soinside.com 2019 - 2024. All rights reserved.