[英]How to concatenate json elements with JsonPath (JayWay)
有一个简单的json:
{ "Keys": [
{"Format": "A", "Subtype": "A1"},
{"Format": "A", "Subtype": "A2"},
{"Format": "B", "Subtype": "A1"}]
}
我想使用 JsonPath 表达式(没有 Java 特定实现)生成这个结果(格式 + 子类型连接):
AA1
AA2
BA1
是否可以使用 jsonPath 连接字符串元素?
谢谢
因此,以下将给出AA1
。
$.concat($.Keys[0].Format,$.Keys[0].Subtype)
同样
$.concat($.Keys[1].Format,$.Keys[1].Subtype) -- AA2
$.concat($.Keys[2].Format,$.Keys[2].Subtype) -- BA1
我知道这篇文章是前一段时间,但我正在寻找类似的问题。 这不是解决方案吗?
$.Keys[0].Format$.Keys[0].Subtype
$.Keys[1].Format$.Keys[1].Subtype
$.Keys[2].Format$.Keys[2].Subtype
您可以构建 JSON 路径表达式,例如:
$.Keys[0].Format -- A
$.Keys[1].Format -- A
$.Keys[2].Format -- B
并在下面的链接中引用此 SO 线程以最终使用 Jayway 解析它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.