我有以下格式的json(不仅限于本例中的两个文档,可能还有很多,更多):
[{
"ownerId": "XTV7I728",
"vehicleId": "999",
"engineId": "1",
"engineName": "Standard Engine",
"engineHp": 300
},
{
"ownerId": "XTV7I728",
"vehicleId": "999",
"engineId": "2",
"engineName": "Custom Engine",
"engineHp": 450
}]
我想基本上将这些json文档的多个“非规范化”到一个json文档中,如下所示:
[{
"ownerId": "XTV7I728",
"vehicleId": "999",
"engines": [
{
"engineId": "1",
"engineName": "Standard Engine",
"engineHp": 300
},
{
"engineId": "2",
"engineName": "Custom Engine",
"engineHp": 450
}
]
}]
还想添加类似
的内容[{
"ownerId": "XTV7I728",
"vehicleId": "999",
"engineId": "1",
"engineName": "Standard Engine",
"engineHp": 300
},
{
"ownerId": "XTV7I728",
"vehicleId": "999",
"engineId": "2",
"engineName": "Custom Engine",
"engineHp": 450
},
{
"ownerId": "TY789021",
"vehicleId": "999",
"engineId": "1",
"engineName": "Standard Engine",
"engineHp": 300
}]
应该转变为:
[{
"ownerId": "XTV7I728",
"vehicleId": "999",
"engines": [
{
"engineId": "1",
"engineName": "Standard Engine",
"engineHp": 300
},
{
"engineId": "2",
"engineName": "Custom Engine",
"engineHp": 450
}
]
},
{
"ownerId": "TY789021",
"vehicleId": "999",
"engines": [
{
"engineId": "1",
"engineName": "Standard Engine",
"engineHp": 300
}
]
}]
到目前为止,我对Jolt的有限理解使我相信这种转变是可能的,但是目前还不清楚如何从提供的文档中解决这个问题。任何有关Jolt规范的帮助都将非常感谢!!