英文:
To Display the attributes, which are taken from the array of objects, flattened in Jolt Transform
问题
Desired output is:
{
"citycode": "34343",
"branch": "cityname",
"Marks": "L",
"LANGUAGE-ID": "de",
"Occupation": "security",
"LANGUAGE-ID": "fr",
"Occupation": "officer",
"LANGUAGE-ID": "en",
"Occupation": "superior"
}
Current jolt output is below:
{
"citycode": "34343",
"branch": "cityname",
"Marks": "L",
"LANGUAGE-ID": ["de", "fr", "en"],
"Occupation": ["security", "officer", "superior"]
}
Need to split the array elements separately. Can you please help?
英文:
I have below jolt input,
{
"citycode": "34343",
"branch": "cityname",
"changeDatetime": 1677063272522,
"Marks": "L",
"designations": [
{
"designation": "security ",
"Language": "de"
},
{
"designation": "officer",
"Language": "fr"
},
{
"designation": "superior",
"Language": "en"
}
]
}
Desired output is:
{
"citycode" : "34343",
"branch" : "cityname",
"Marks" : "L",
"LANGUAGE-ID" : "de",
"Occupation" : "security",
"LANGUAGE-ID" : "fr",
"Occupation" : "officer",
"LANGUAGE-ID" : "en",
"Occupation" : "superior"
}
current jolt output is below:
{
"citycode" : "34343",
"branch" : "cityname",
"Marks" : "L",
"LANGUAGE-ID" : [ "de", "fr", "en" ],
"Occupation" : [ "security ", "officer", "superior" ]
}
Need to split the array elements separately.
Can you please help
答案1
得分: 2
以下是翻译好的部分:
[
{
"operation": "shift",
"spec": {
"*": "&", // 除了 "designations" 数组之外的所有元素
"designations": {
"*": { // 遍历 "designations" 数组的索引
"L*": "LANGUAGE-ID_&1",
"d*": "Occupation_&1"
}
}
}
}
]
此输出会为每个 LANGUAGE-ID
和 Occupation
键添加递增的索引(0、1、2)。
英文:
The current desired JSON output is invalid, but presumably you need the following one
[
{
"operation": "shift",
"spec": {
"*": "&", // all elements other than the "designations" array
"designations": {
"*": { // loop through the indexes of the "designations" array
"L*": "LANGUAGE-ID_&1",
"d*": "Occupation_&1"
}
}
}
}
]
which suffixes incremental(0,1,2) indexes per each LANGUAGE-ID
and Occupation
key
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论