我有一个JSON对象数组,需要将其转换为与我的方案一致的新JSON对象数组。我不熟悉Jolt,但我的输出不是我所需要的。我尝试在其中使用[&1]和@运算符,但尚未获得所需的输出。
我的意见:
{
"totalCount": 2,
"entities": {
"people": [
{
"uniqueIdentifier": "0105",
"common": {
"firstName": "Bob",
"lastName": "Smith",
"geoLocation": {
"geometry": {
"point": {
"coordinates": [
39.93479016,
47.21850072
]
}
}
},
"timeOfReporting": "2019-11-18T18:36:10Z"
},
"type": "PERSON",
"parent": {
"firstName": "Jane",
"lastName": "Smith"
}
},
{
"uniqueIdentifier": "0106",
"common": {
"firstName": "Joe",
"lastName": "Green",
"geoLocation": {
"geometry": {
"point": {
"coordinates": [
39.93479016,
47.21850072
]
}
}
},
"timeOfReporting": "2019-11-18T18:36:10Z"
},
"Type": "PERSON",
"parent": {
"firstName": "John",
"lastName": "Green"
}
}
]
}
}
我的震动规格:
[
{
"operation": "shift",
"spec": {
"entities": {
"people": {
"*": {
"uniqueIdentifier": "Person.Id",
"type": "Person.Type",
"parent": {
"firstName": "Person.Parent.FirstName",
"lastName": "Person.Parent.LastName"
},
"common": {
"firstName": "Person.FirstName",
"lastName": "Person.LastName",
"timeOfReporting": "Person.DateCreated",
"geoLocation": {
"geometry": {
"point": {
"coordinates": {
"0": "Person.Locations.Location.Longitude",
"1": "Person.Locations.Location.Latitude"
}
}
}
}
}
}
}
}
}
},
{
"operation": "default",
"spec": {
"Person": {
"Processed": "false"
}
}
}
]
电流输出:
{
"Person" : {
"DateCreated" : [ "2019-11-18T18:36:10Z", "2019-11-18T18:36:10Z" ],
"FirstName" : [ "Bob", "Joe" ],
"Id" : [ "0105", "0106" ],
"LastName" : [ "Smith", "Green" ],
"Locations" : {
"Location" : {
"Latitude" : [ 47.21850072, 47.21850072 ],
"Longitude" : [ 39.93479016, 39.93479016 ]
}
},
"Parent" : {
"FirstName" : [ "Jane", "John" ],
"LastName" : [ "Smith", "Green" ]
},
"Processed" : "false",
"Type" : "PERSON"
}
}
预期输出:
{
"Person":{
"DateCreated": "2019-11-18T18:36:10Z",
"FirstName": "Bob",
"LastName" "Smith"
"Id": "0105",
"Locations": {
"Location": {
"Latitude": 47.2184,
"Longitude": 39.7854
}
},
"Parent": {
"FirstName": "Jane",
"LastName": "Smith"
},
"Processed": "false",
"Type": "PERSON"
},
"Person": {
"DateCreated": "2019-11-18T18:36:10Z",
"FirstName": "Joe",
"LastName": "Green"
"Id": "0106",
"Locations": {
"Location": {
"Latitude": 42.2184,
"Longitude": 31.7854
}
},
"Parent": {
"FirstName": "John",
"LastName": "Green"
},
"Processed": "false",
"Type": "PERSON"
},
}
1条答案
按热度按时间5lhxktic1#
您不能在所需的输出中有两个人键。但是,您可以根据您所需的输出使用以下震动规格之一:
1.将所有person对象保存在数组中
2.将每个人的对象保存在新对象中: