以下のjson文字列をJavaオブジェクトに変換しようとしていますが、空のオブジェクトを取得しています。prop2 オブジェクトの下には、任意の数のキーと値のペアが存在できます (ここで、キーは文字列で、値は配列です)。
{
"Level1": {
"prop1": "",
"prop2": {
"one": [{
"ip": "1.2.3.4",
"port": "100"
}],
"ten": [{
"ip": "10.20.20.10",
"port": "200"
}]
}
}
}
私はこのクラス構造を持っていますが、ipAndPorts マップを空として取得しています。
@JsonIgnoreProperties(ignoreUnknown = true)
static class Root {
@JsonProperty("Level1")
private Level1 level1;
}
@JsonIgnoreProperties(ignoreUnknown = true)
static class Level1 {
@JsonProperty("prop2")
private Prop2 prop2;
}
@JsonIgnoreProperties(ignoreUnknown = true)
static class Prop2 {
private Map<String, List<IpAndPort>> ipAndPorts = Collections.emptyMap();
}
@JsonIgnoreProperties(ignoreUnknown = true)
static class IpAndPort {
@JsonProperty("port")
private String port;
}
「prop2」を正しく表すために、私のJavaクラスはどのように見えるべきですか?