我有一个复杂的 JSON 字符串,我尝试使用 AutoBean 解析它。
JSON 字符串如下所示:
`{
"status": "OK",
"result": {
"geometry": [
[
{
"X": 268347.4,
"Y": 6743983.1
},
{
"X": 268341.1,
"Y": 6743989.7
}
],
[
{
"X": 268378.15,
"Y": 6743972.7
},
{
"X": 268347.4,
"Y": 6743983.1
}
]
]
}
}`
我创建了这个界面
public interface BrancheAutoBean {
String getResult();
GeometryModel getGeometryModel()
}
public interface GeometryModel {
@PropertyName("geometry")
List<Geometry> getGeometry();
}
public interface Geometry{
@PropertyName("X")
Double getX();
@PropertyName("Y")
Double getY();
}
我怎样才能让它工作?以及如何将 X 和 Y 数组添加到几何中我发现了一些示例,例如在解析 bean 时添加 X 和 Y:
Geometry bean =AutoBeanCodex.decode(factory, GeometryModel.class, "{\"Geometry\": " + strResponse + "}").as();
但我的应用程序必须实现 générique 解析。提前谢谢。