源JSON:
{
"accounts": [
{
"name": "accounts/189134493",
"createTime": "2021-02-08T08:55:53.722Z",
"updateTime": "2021-02-08T08:55:53.722Z"
},
{
"name": "accounts/192303354",
"createTime": "2021-03-16T14:22:04.865Z",
"updateTime": "2021-03-16T14:22:04.865Z"
}
],
"nextPageToken": "APDpoXMhpjzh_oJqiqip6upnMH"
}
预期:
[
{
"id": "1891344",
"createTime": "2021-02-08T08:55:53.722Z",
"updateTime": "2021-02-08T08:55:53.722Z"
},
{
"id": "1923033",
"createTime": "2021-03-16T14:22:04.865Z",
"updateTime": "2021-03-16T14:22:04.865Z"
}
]
我只能通过简单的移位操作从accounts
数组中解嵌套值:
"spec": {
"*": {
"*": {
"*": "[&1].&"
}
}
}
现在我需要从name
中获取值,并在accounts/
之后获取值并将其存储为id
。
1条答案
按热度按时间46scxncf1#
您可以在modify转换中连续使用***split***和***join***函数,例如
网站http://jolt-demo.appspot.com/上的demo是
编辑:如果name属性的值有多个斜杠,如注解示例所示
并希望提取最后一个斜线之后的部分,例如
则更倾向于使用以下包含***lastElement***函数的规范: