Jolt - 展平 JSON 数组
Jolt - Flatten JSON array
输入:
{
"creatives": [
{
"link_promo": [
"https://facebook.com/123",
"https://facebook.com/456"
]
},
{
"link_promo": [
"https://facebook.com/789",
"https://facebook.com/101112"
]
},
{
"link_promo": [
"https://facebook.com/121314",
"https://facebook.com/141516"
]
}
]
}
规格:
[
{
"operation": "shift",
"spec": {
"creatives": {
"*": {
"link_promo": "promo_links[]"
}
}
}
}
]
输出:
{
"promo_links": [
[
"https://facebook.com/123",
"https://facebook.com/456"
],
[
"https://facebook.com/789",
"https://facebook.com/101112"
],
[
"https://facebook.com/121314",
"https://facebook.com/141516"
]
]
}
期望的输出:
{
"promo_links": [
"https://facebook.com/123",
"https://facebook.com/456",
"https://facebook.com/789",
"https://facebook.com/101112",
"https://facebook.com/121314",
"https://facebook.com/141516"
]
}
大家好,我需要将嵌套列表展平为数组,如上所述。
大家好,我需要将嵌套列表展平为数组,如上所述。
有什么想法可以修改我的 jolt 规范以实现该输出吗?
替换零件再嵌套一步
"link_promo": "promo_links[]"
与 "link_promo": { "*": "promo_links" }
为了到达 JSON 的最里面,如下面的规范
[
{
"operation": "shift",
"spec": {
"creatives": {
"*": {
"link_promo": {
"*": "promo_links"
}
}
}
}
}
]
站点上的演示 http://jolt-demo.appspot.com/
输入:
{
"creatives": [
{
"link_promo": [
"https://facebook.com/123",
"https://facebook.com/456"
]
},
{
"link_promo": [
"https://facebook.com/789",
"https://facebook.com/101112"
]
},
{
"link_promo": [
"https://facebook.com/121314",
"https://facebook.com/141516"
]
}
]
}
规格:
[
{
"operation": "shift",
"spec": {
"creatives": {
"*": {
"link_promo": "promo_links[]"
}
}
}
}
]
输出:
{
"promo_links": [
[
"https://facebook.com/123",
"https://facebook.com/456"
],
[
"https://facebook.com/789",
"https://facebook.com/101112"
],
[
"https://facebook.com/121314",
"https://facebook.com/141516"
]
]
}
期望的输出:
{
"promo_links": [
"https://facebook.com/123",
"https://facebook.com/456",
"https://facebook.com/789",
"https://facebook.com/101112",
"https://facebook.com/121314",
"https://facebook.com/141516"
]
}
大家好,我需要将嵌套列表展平为数组,如上所述。 大家好,我需要将嵌套列表展平为数组,如上所述。 有什么想法可以修改我的 jolt 规范以实现该输出吗?
替换零件再嵌套一步
"link_promo": "promo_links[]"
与 "link_promo": { "*": "promo_links" }
为了到达 JSON 的最里面,如下面的规范
[
{
"operation": "shift",
"spec": {
"creatives": {
"*": {
"link_promo": {
"*": "promo_links"
}
}
}
}
}
]
站点上的演示 http://jolt-demo.appspot.com/