Я работаю над приложением Spring Boot и пытаюсь проанализировать ответ JSON, который имеет значение Dynami c. Ответ JSON выглядит следующим образом:
{
"bitcoin": {
"usd": 9890.12,
"usd_24h_change": -2.5190541643275113,
"eur": 9064.07,
"eur_24h_change": -2.17888644719709,
"gbp": 7658.04,
"gbp_24h_change": -2.7084073322373126
}
}
Проблема, с которой я сталкиваюсь, заключается в том, что ценность монеты будет уникальной для каждого запроса. Как я могу сопоставить это значение с чем-то динамическим c через Джексона?
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"coinid"
})
public class coinprices {
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.WRAPPER_OBJECT,
property = "type")
private Coinid coinid;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
public coinprices(Object coinid) {
this.coinid = (Coinid) coinid;
}
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.WRAPPER_OBJECT,
property = "type")
public Coinid getCoinid() {
return (Coinid) coinid;
}
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.WRAPPER_OBJECT,
property = "type")
public void setCoinid(Coinid coinid) {
this.coinid = coinid;
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}
}
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"usd",
"usd_24h_change",
"eur",
"eur_24h_change",
"gbp",
"gbp_24h_change"
})
public class Coinid {
@JsonProperty("usd")
private Double usd;
@JsonProperty("usd_24h_change")
private Double usd24hChange;
@JsonProperty("eur")
private Double eur;
@JsonProperty("eur_24h_change")
private Double eur24hChange;
@JsonProperty("gbp")
private Double gbp;
@JsonProperty("gbp_24h_change")
private Double gbp24hChange;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
@JsonProperty("usd")
public Double getUsd() {
return usd;
}
@JsonProperty("usd")
public void setUsd(Double usd) {
this.usd = usd;
}
@JsonProperty("usd_24h_change")
public Double getUsd24hChange() {
return usd24hChange;
}
@JsonProperty("usd_24h_change")
public void setUsd24hChange(Double usd24hChange) {
this.usd24hChange = usd24hChange;
}
@JsonProperty("eur")
public Double getEur() {
return eur;
}
@JsonProperty("eur")
public void setEur(Double eur) {
this.eur = eur;
}
@JsonProperty("eur_24h_change")
public Double getEur24hChange() {
return eur24hChange;
}
@JsonProperty("eur_24h_change")
public void setEur24hChange(Double eur24hChange) {
this.eur24hChange = eur24hChange;
}
@JsonProperty("gbp")
public Double getGbp() {
return gbp;
}
@JsonProperty("gbp")
public void setGbp(Double gbp) {
this.gbp = gbp;
}
@JsonProperty("gbp_24h_change")
public Double getGbp24hChange() {
return gbp24hChange;
}
@JsonProperty("gbp_24h_change")
public void setGbp24hChange(Double gbp24hChange) {
this.gbp24hChange = gbp24hChange;
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}
}