【发布时间】:2016-12-19 12:52:19
【问题描述】:
我正在尝试从 json 文件中获取一组对象,但我遇到了问题。
path.get("wgcTournaments.items")
我应该使用什么路径来获取项目中的所有项目(项目 0、项目 1、项目 2 ...)?
你能给我一个建议吗?
Json 示例
{
"wgcTournaments": {
"items": {
"jcr:primaryType": "nt:unstructured",
"item0": {
"jcr:primaryType": "nt:unstructured",
"test": "test",
"test1": "test1"
},
"item1": {
"jcr:primaryType": "nt:unstructured",
"test": "test",
"test1": "test1"
},
"item2": {
"jcr:primaryType": "nt:unstructured",
"test": "test",
"test1": "test1"
},
"item3": {
"jcr:primaryType": "nt:unstructured",
"test": "test",
"test1": "test1"
}
}
}
}
从项目对象中过滤项目的最佳方法,但我不明白如何使用 json 路径进行操作。
【问题讨论】:
-
您正在尝试获取
MyClass对象数组,但在您的 JSON 中您有一个对象,而不是对象数组。 -
AntoineB 我想得到一个由 item0、item1、item2 组成的数组,看起来它们是一个对象数组
-
看看我回答的最后一部分。
标签: java rest-assured rest-assured-jsonpath