CosminO:
この構造を考慮すると、親のプロパティの内部オブジェクト(プロパティ、型フィールド)の配列を取得するための正しい表記ものです。
{"parent":
[
{"property":[2,5],"type":2},
{"property":[1,2],"type":1},
{"property":[4,0],"type":0}
],
"prop2":"something"
}
現在、Javaのようになります
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Parent{
<WHAT TO PUT HERE??>
List<PropertyTypeObj> propertyTypes;
}
これは、のような大規模なものの一部です:
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Container{
@JsonProperty("parent")
List<Parent> parent;
@JsonProperty("prop2")
String prop2
}
解決策は、親要素の作成バイパスにし、代わりに使用PropertyTypeObject自体を
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Container{
@JsonProperty("parent")
List<PropertyTypeObject> properties;
@JsonProperty("prop2")
String prop2
}
そして持つようPropertyTypeObjectを指定します @JsonRootName("parent")
わかりやすくするために承認された答えを参照してください。
デビッド・ロレンツォMARINO:
可能なクラス構造は以下の通りであります:
public class External {
private List<External.Internal> parent;
private String prop2;
@JsonRootName("parent")
public static class Internal {
private List<Integer> property;
private Integer type;
}
}
どこ外部のクラスがあります。
- 親インナー要素のリスト(JSONの配列)であるプロパティ
- PROP2 String型のプロパティ
各要素のために持っていた内部クラス:
- プロパティの整数のList型のプロパティ(JSONの配列)
- 型整数型のプロパティ