我遇到以下问题: 我得到了JSON输入
{
"Vorname":"Vorname1 Vorname2",
"Name":"Nachname
}
输出应为:
{ "such":"NachnameVorname1Vorname2" }
我的JOLT规范是:
[{
"operation": "modify-default-beta",
"spec": {
"FullName": "=concat(@(1,Vorname),' ' ,@(1,Name))",
"RFullName": "=concat(@(1,Name),@(1,Vorname))"
}
}, {
"operation": "shift",
"spec": {
"PersNr": "ymitarb",
"Austrittsdatum": "ymaust",
"RFullName": "such",
"FullName": "name"
}
}, {
"operation": "default",
"spec": {
"name": "${fname}",
"such":"$(rfname)",
"ymitarb": "${nummer}"
}
}]
我得到的输出是:
{
"such": "NachnameVorname1 Vorname2",
"name": "Vorname1 Vorname2 Nachname",
"ymitarb": ""
}
它应该是{“ such”:“ NachnameVorname1Vorname2”}
我的第二个想法是将Vorname拆分为Vorname_x
[{
"operation": "modify-default-beta",
"spec": {
"FullName": "=concat(@(1,Vorname),' ' ,@(1,Name))",
"RFullName": "=concat(@(1,Name),@(1,Vorname))"
}
}, {
"operation": "shift",
"spec": {
"Vorname": {
"* * *": {
"$(0,1)": "Vorname_1",
"$(0,2)": "Vorname_2",
"$(0,3)": "Vorname_3"
},
"* *": {"$(0,1)": "Vorname_1",
"$(0,2)": "Vorname_2"}
},
"PersNr": "ymitarb",
"Austrittsdatum": "ymaust",
"RFullName": "such",
"FullName": "name"
}
}, {
"operation": "default",
"spec": {
"name": "${fname}",
"such":"$(rfname)",
"ymitarb": "${nummer}"
}
}]
这里的输出是
{
"Vorname_1": "Vorname1",
"Vorname_2": "Vorname2",
"such": "NachnameVorname1 Vorname2",
"name": "Vorname1 Vorname2 Nachname",
"ymitarb": ""
}
我无法在concat中使用Vorname_1和Vorname_2的值。 由于我无法找到任何解决方案
有任何帮助:)!
答案 0 :(得分:1)
规格
[
{
"operation": "shift",
"spec": {
// split Vorname by a space
"Vorname": {
"* *": {
"$(0,1)": "vorFront",
"$(0,2)": "vorBack"
}
},
// pass Name thru
"Name": "Name"
}
},
{
"operation": "modify-default-beta",
"spec": {
// concat the names now that the space is gone
"such": "=concat(@(1,Name),@(1,vorFront),@(1,vorBack))"
}
}
]
答案 1 :(得分:0)
那是我的规格:
[{
"operation": "modify-default-beta",
"spec": {
"FullName": "=concat(@(1,Vorname_1),' ',@(1,Vorname_2),' ',@(1,Vorname_3),' ',@(1,Name))",
"RFullName": "=concat(@(1,Name),@(1,Vorname_1),@(1,Vorname_2),@(1,Vorname_3))"
}
}, {
"operation": "shift",
"spec": {
"Vorname": {
"* * *": {
"$(0,1)": "Vorname_1",
"$(0,2)": "Vorname_2",
"$(0,3)": "Vorname_3"
},
"* *": {
"$(0,1)": "Vorname_1",
"$(0,2)": "Vorname_2"
}
},
"Vorname": "Vorname",
"PersNr": "ymitarb",
"Name": "Name",
"Austrittsdatum": "ymaust",
"RFullName": "such",
"FullName": "name"
}
}, {
"operation": "default",
"spec": {
"name": "${fname}",
"such": "${rfname}",
"ymitarb": "${nummer}"
}
}]
输入是:
{
"Vorname": "Hans Jürgen",
"Name": "Franz"
}
我得到的输出是:
{
"Vorname": "Hans Jürgen",
"Name": "Franz",
"such": "Franz",
"name": " Franz",
"ymitarb": ""
}
输出应为:
{
"Vorname_1": "Hans" //somehow vorname_1 and vorname_2 dosnt work if i
"Vorname_2": " Jürgen" // change your spec
"Vorname": "Hans Jürgen",
"Name": "Franz",
"such": "FranzJürgenHans",
"name": "Hans Jürgen Franz",
"ymitarb": ""
}
我在做什么错?另外,如果“ vorname”有1个空格或2个空格,则它的工作方式 但是如果规范还不接受空格,应该怎么看?
"*": {
"$(0,1)": "Vorname_1"
}
辛苦工作