[英]Jolt transformation for extracting data from nested list
What is the Jolt Spec for extracting data from nested list 从嵌套列表中提取数据的Jolt Spec是什么
I have been experimenting with apache nifi , I want to use joltransformation processor for parsing json flow file content ,but I am unable to parse nested list 我一直在尝试apache nifi,我想使用joltransformation处理器来解析json流文件内容,但是我无法解析嵌套列表
Input JSON - 输入JSON-
{
"posts": [
{
"network": "test",
"photos": [
{
"a": 1.7722222222222221,
"s": "https://a.com",
"m": "https://b.com",
"l": "https://ccccc.com"
}
]
},
{
"network": "test1",
"photos": [
{
"a": 1.7722222222222221,
"s": "https://d.com",
"m": "https://e.com",
"l": "https://fffff.com"
}
]
}
]
}
JOLT Transformation file - JOLT转换文件-
[
{
"operation": "shift",
"spec": {
"posts": {
"*": {
"network": "[&1].profile",
"photos": { "0": { "l": "[&1].p" } }
}
}
}
}
]
Expected Output - 预期产出-
[
{
"profile" : "test",
"p" : "https://ccccc.com"
},
{
"profile" : "test1",
"p" : "https://fffff.com"
}
]
Actual Output - 实际输出-
[
{
"profile" : "test",
"p" : [ "https://ccccc.com", "https://ffffff.com" ]
},
{
"profile" : "test1"
}
]
Please help me , I am unable to figure out what I am doing wrong 请帮助我,我无法弄清楚我在做什么错
You were close 你很亲密
[
{
"operation": "shift",
"spec": {
"posts": {
"*": {
"network": "[&1].profile",
"photos": {
"0": {
"l": "[&3].p"
}
}
}
}
}
}
]
The [&3].p
is the important part as that means the index is used from 3 levels up, which is the one from posts. [&3].p
是重要的部分,因为这意味着从3个级别开始使用索引,这是从帖子开始的级别。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.