规范中的 JOLT 变换数组索引问题
JOLT transform array index issue in spec
如果我在输入中有集合作为数组。如果有缺失值,我正在使用 'modify-default-beta' 写入默认值。
我遇到的唯一问题是 FacTie 生成多个,因为它不是我所期望的。
输入 Json 特征数组:
{
"type": "Collection",
"features": [
{
"type": "Feature",
"geometry": {
"coordinates": [
121.63646666666666,
29.10262638888889
]
},
"properties": {
"clientId": "1123",
"category": "44500",
"datetime_created": " 2018-11-29 10:48:43",
"facTieSk": "-1"
}
},
{
"type": "Feature",
"geometry": {
"coordinates": [
121.63646666666666,
29.10262638888889
]
},
"properties": {
"clientId": "1124",
"category": "44500",
"datetime_created": " 2018-11-29 10:48:43",
"facTieSk": "-1"
}
}
]
}
规格:
[
{
"operation": "shift",
"spec": {
"features": {
"*": {
"properties": {
"@(1,type)": {
"Feature": {
"@(3,clientId)": "Composite[&4].FacComp.Fac.SysSource",
"@(3,geometry)": {
"@coordinates": {
"*": "Composite[&6].FacComp.geometry.coordinates[]"
}
},
"@(2,category)": "Composite[&4].FacComp.Fac.Category",
"@(2,datetime_created)": ["Composite[&4].FacComp.Fac.DatetimeCreated", "Composite[&4].FacComp.FacTie[&4].DatetimeCreated"],
"@(2,facTieSk)": "Composite[&4].FacComp.FacTie[&4].FacTieSk"
}
}
}
}
}
}
},
{
"operation": "modify-default-beta",
"spec": {
"Composite": {
"*": {
"FacComp?": {
"Fac": {
"FacSk": "-1",
"CoordBasis": "2"
},
"FacTie": {
"*": {
"FacTieSk": "-1",
"TieFromSk": "-1",
"TieToSk": "-1",
"TieToEntity": "FAC"
}
}
}
}
}
}
}
]
预计输出:
{
"Composite": [{
"FacComp": {
"geometry": {
"coordinates": [121.63646666666666, 29.10262638888889]
},
"Fac": {
"Category": "44500",
"DatetimeCreated": " 2018-11-29 10:48:43",
"FacSk": "-1",
"CoordBasis": "2"
},
"FacTie": [{
"DatetimeCreated": " 2018-11-29 10:48:43",
"FacTieSk": "-1",
"TieFromSk": "-1",
"TieToSk": "-1",
"TieToEntity": "FAC"
}
]
}
}, {
"FacComp": {
"geometry": {
"coordinates": [121.63646666666666, 29.10262638888889]
},
"Fac": {
"Category": "44500",
"DatetimeCreated": " 2018-11-29 10:48:43",
"FacSk": "-1",
"CoordBasis": "2"
},
"FacTie": [{
"DatetimeCreated": " 2018-11-29 10:48:43",
"FacTieSk": "-1",
"TieFromSk": "-1",
"TieToSk": "-1",
"TieToEntity": "FAC"
}
]
}
}
]
}
相反,我的输出低于输出(请参阅第二个元素中的 FacTie 有 2 个项目而不是一个。
{
"Composite" : [ {
"FacComp" : {
"geometry" : {
"coordinates" : [ 121.63646666666666, 29.10262638888889 ]
},
"Fac" : {
"Category" : "44500",
"DatetimeCreated" : " 2018-11-29 10:48:43",
"FacSk" : "-1",
"CoordBasis" : "2"
},
"FacTie" : [ {
"DatetimeCreated" : " 2018-11-29 10:48:43",
"FacTieSk" : "-1",
"TieFromSk" : "-1",
"TieToSk" : "-1",
"TieToEntity" : "FAC"
} ]
}
}, {
"FacComp" : {
"geometry" : {
"coordinates" : [ 121.63646666666666, 29.10262638888889 ]
},
"Fac" : {
"Category" : "44500",
"DatetimeCreated" : " 2018-11-29 10:48:43",
"FacSk" : "-1",
"CoordBasis" : "2"
},
"FacTie" : [ {
"FacTieSk" : "-1",
"TieFromSk" : "-1",
"TieToSk" : "-1",
"TieToEntity" : "FAC"
}, {
"DatetimeCreated" : " 2018-11-29 10:48:43",
"FacTieSk" : "-1",
"TieFromSk" : "-1",
"TieToSk" : "-1",
"TieToEntity" : "FAC"
} ]
}
} ]
}
第二部分 FacComp 中有一个空值(在查看第一个规范后的输出时),因此在您的两个规范之间添加以下代码以删除空值:
{
"operation": "modify-overwrite-beta",
"spec": {
"*": "=recursivelySquashNulls"
}
},
如果我在输入中有集合作为数组。如果有缺失值,我正在使用 'modify-default-beta' 写入默认值。 我遇到的唯一问题是 FacTie 生成多个,因为它不是我所期望的。
输入 Json 特征数组:
{
"type": "Collection",
"features": [
{
"type": "Feature",
"geometry": {
"coordinates": [
121.63646666666666,
29.10262638888889
]
},
"properties": {
"clientId": "1123",
"category": "44500",
"datetime_created": " 2018-11-29 10:48:43",
"facTieSk": "-1"
}
},
{
"type": "Feature",
"geometry": {
"coordinates": [
121.63646666666666,
29.10262638888889
]
},
"properties": {
"clientId": "1124",
"category": "44500",
"datetime_created": " 2018-11-29 10:48:43",
"facTieSk": "-1"
}
}
]
}
规格:
[
{
"operation": "shift",
"spec": {
"features": {
"*": {
"properties": {
"@(1,type)": {
"Feature": {
"@(3,clientId)": "Composite[&4].FacComp.Fac.SysSource",
"@(3,geometry)": {
"@coordinates": {
"*": "Composite[&6].FacComp.geometry.coordinates[]"
}
},
"@(2,category)": "Composite[&4].FacComp.Fac.Category",
"@(2,datetime_created)": ["Composite[&4].FacComp.Fac.DatetimeCreated", "Composite[&4].FacComp.FacTie[&4].DatetimeCreated"],
"@(2,facTieSk)": "Composite[&4].FacComp.FacTie[&4].FacTieSk"
}
}
}
}
}
}
},
{
"operation": "modify-default-beta",
"spec": {
"Composite": {
"*": {
"FacComp?": {
"Fac": {
"FacSk": "-1",
"CoordBasis": "2"
},
"FacTie": {
"*": {
"FacTieSk": "-1",
"TieFromSk": "-1",
"TieToSk": "-1",
"TieToEntity": "FAC"
}
}
}
}
}
}
}
]
预计输出:
{
"Composite": [{
"FacComp": {
"geometry": {
"coordinates": [121.63646666666666, 29.10262638888889]
},
"Fac": {
"Category": "44500",
"DatetimeCreated": " 2018-11-29 10:48:43",
"FacSk": "-1",
"CoordBasis": "2"
},
"FacTie": [{
"DatetimeCreated": " 2018-11-29 10:48:43",
"FacTieSk": "-1",
"TieFromSk": "-1",
"TieToSk": "-1",
"TieToEntity": "FAC"
}
]
}
}, {
"FacComp": {
"geometry": {
"coordinates": [121.63646666666666, 29.10262638888889]
},
"Fac": {
"Category": "44500",
"DatetimeCreated": " 2018-11-29 10:48:43",
"FacSk": "-1",
"CoordBasis": "2"
},
"FacTie": [{
"DatetimeCreated": " 2018-11-29 10:48:43",
"FacTieSk": "-1",
"TieFromSk": "-1",
"TieToSk": "-1",
"TieToEntity": "FAC"
}
]
}
}
]
}
相反,我的输出低于输出(请参阅第二个元素中的 FacTie 有 2 个项目而不是一个。
{
"Composite" : [ {
"FacComp" : {
"geometry" : {
"coordinates" : [ 121.63646666666666, 29.10262638888889 ]
},
"Fac" : {
"Category" : "44500",
"DatetimeCreated" : " 2018-11-29 10:48:43",
"FacSk" : "-1",
"CoordBasis" : "2"
},
"FacTie" : [ {
"DatetimeCreated" : " 2018-11-29 10:48:43",
"FacTieSk" : "-1",
"TieFromSk" : "-1",
"TieToSk" : "-1",
"TieToEntity" : "FAC"
} ]
}
}, {
"FacComp" : {
"geometry" : {
"coordinates" : [ 121.63646666666666, 29.10262638888889 ]
},
"Fac" : {
"Category" : "44500",
"DatetimeCreated" : " 2018-11-29 10:48:43",
"FacSk" : "-1",
"CoordBasis" : "2"
},
"FacTie" : [ {
"FacTieSk" : "-1",
"TieFromSk" : "-1",
"TieToSk" : "-1",
"TieToEntity" : "FAC"
}, {
"DatetimeCreated" : " 2018-11-29 10:48:43",
"FacTieSk" : "-1",
"TieFromSk" : "-1",
"TieToSk" : "-1",
"TieToEntity" : "FAC"
} ]
}
} ]
}
第二部分 FacComp 中有一个空值(在查看第一个规范后的输出时),因此在您的两个规范之间添加以下代码以删除空值:
{
"operation": "modify-overwrite-beta",
"spec": {
"*": "=recursivelySquashNulls"
}
},