Код: Выделить всё
[
{
"id": "age",
"name": "Age",
"type": "string",
"value": "730 days +"
},
{
"id": "v2Score",
"name": "V2 Score",
"type": "number",
"value": 5.9
},
{
"id": "maturity",
"name": "Maturity",
"type": "string",
"value": "High"
},
{
"id": "coverage",
"name": "Product Coverage",
"type": "string",
"value": "Low"
},
{
"id": "threat_intensity",
"name": "Threat Intensity",
"type": "string",
"value": "Very Low"
},
{
"id": "threat_recency",
"name": "Threat Recency",
"type": "string",
"value": "No recorded events"
},
{
"id": "threat_sources",
"name": "Threat Sources",
"type": "string",
"value": "No recorded events"
}
]
Я добрался до этого, прежде чем застрял на что делать
Код: Выделить всё
@JsonCreator
Context(
@JsonProperty("age") Age age,
@JsonProperty("coverage") Coverage coverage
// rest of params similar
) {
// basic constructor
}
Код: Выделить всё
context.getAge() // Age.MORE_THAN_TWO_YEARS
context.getMaturity() // Maturity.HIGH
context.getCoverage() // Coverage.LOW
context.getThreatIntensity() // ThreatIntensity.VERY_LOW
context.getThreatRecency() // ThreatRecency.NONE
Я полагаю, мне нужно каким-то образом использовать @JsonTypeInfo для каждого аргумента конструктора?
Я также знаю, как создать для этого собственный десериализатор, но делаю это делает код гораздо более хрупким, особенно если он будет расширен или изменен в будущем.
Подробнее здесь: https://stackoverflow.com/questions/786 ... n-property