如何使用 JsonPath (JayWay) 连接 json 元素

gos*_*din 5 java json jsonpath

有一个简单的 json:

{ "Keys": [
  {"Format": "A", "Subtype": "A1"},
  {"Format": "A",  "Subtype": "A2"},
  {"Format": "B",  "Subtype": "A1"}]
}
Run Code Online (Sandbox Code Playgroud)

我想使用 JsonPath 表达式(没有 Java 特定实现)生成此结果(格式 + 子类型串联):

 AA1
 AA2
 BA1
Run Code Online (Sandbox Code Playgroud)

是否可以使用 jsonPath 连接字符串元素?

谢谢

小智 0

您可以构建 JSON 路径表达式,例如:

$.Keys[0].Format -- A
$.Keys[1].Format -- A
$.Keys[2].Format -- B
Run Code Online (Sandbox Code Playgroud)

并参考下面的链接来最终使用 Jayway 解析它。