【发布时间】:2016-12-19 13:28:15
【问题描述】:
我已将 GSON 作为 Java 中的 JSON 解析器,但密钥并不总是相同。 例如。我有以下 JSON:
{
"message":"....",
"categories_sorted": [
{
"550e8400-e29b-41d4-a716-446655440000": [
{
"550e8400-e29b-41d4-a716-446655443333": [
{
"550e8400-e29b-41d4-a716-446655448964": []
}
]
},
{
"550e8400-e29b-41d4-a716-446655443334": []
}
]
},
{
"550e8400-e29b-41d4-a716-446655440023": [
{
"550e8400-e29b-41d4-a716-446655442344": []
}
]
}
]
}
我需要解析这棵树“categories_sorted”。我的 Java POJO 对象:
public class CategoryPOJO {
@SerializedName("message")
@Expose
private String message;
@SerializedName("categories_sorted")
@Expose
private JsonArray sortedCategoryItems;
.......
Getters and setters
}
【问题讨论】:
-
我找到了近似版本的决定,但在我的情况下它们不起作用链接:[链接] (gist.github.com/patrickbaumann/897492)