无法使用 jolt 转换在 json 下转换 [英] Unable to transform below json using jolt transformation
本文介绍了无法使用 jolt 转换在 json 下转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 JSON,其中包含玩板球的 studentId,我想要一个组数组的每个对象的学生列表.但是输出正在合并到同一个学生列表中.我尝试迭代每个 studentId 并获得以下输出.我希望得到如下预期/所需格式的输出.有什么帮助吗?
I have a JSON which have studentId's who play cricket and I want a student list for each object of the group array. But the output is getting merged into the same student list. I tried iterating each and every studentId and getting the below output. And I wish to get the output like in the below expected/desired format. Any help?
输入:
{
"studentEligibility": {
"sportsEligibility": {
"cricketEligibility": [
{
"group": [
{
"multiPlayGame": [
{
"studentId": "2aefcb01-fe81-4760-b531-9767c2e6d322_209537"
},
{
"studentId": "2aefcb01-fe81-4760-b531-9767c2e6d322_217649"
}
]
}
]
},
{
"group": [
{
"multiPlayGame": [
{
"studentId": "2aefcb01-fe81-4760-b531-9767c2e6d322_217609"
}
]
},
{
"multiPlayGame": [
{
"studentId": "2aefcb01-fe81-4760-b531-9767c2e6d322_216386"
}
]
}
]
},
{
"group": [
{
"multiPlayGame": [
{
"studentId": "2aefcb01-fe81-4760-b531-9767c2e6d322_217008"
},
{
"studentId": "2aefcb01-fe81-4760-b531-9767c2e6d322_217628"
}
]
}
]
}
]
}
}
}
震动规格:
[
{
"operation": "shift",
"spec": {
"studentEligibility": {
"sportsEligibility": {
"cricketEligibility": {
"*": {
"group": {
"*": {
"multiPlayGame": {
"*": {
"studentId": "team[&5].players[]"
}
}
}
}
}
}
}
}
}
}
]
当前输出:
{
"team": [
{
"players": [
"2aefcb01-fe81-4760-b531-9767c2e6d322_209537",
"2aefcb01-fe81-4760-b531-9767c2e6d322_217649"
]
},
{
"players": [
"2aefcb01-fe81-4760-b531-9767c2e6d322_217609",
"2aefcb01-fe81-4760-b531-9767c2e6d322_216386"
]
},
{
"players": [
"2aefcb01-fe81-4760-b531-9767c2e6d322_217008",
"2aefcb01-fe81-4760-b531-9767c2e6d322_217628"
]
}
]
}
预期/期望输出:
{
"team": [
{
"players": [
"2aefcb01-fe81-4760-b531-9767c2e6d322_209537",
"2aefcb01-fe81-4760-b531-9767c2e6d322_217649"
]
},
{
"players": [
"2aefcb01-fe81-4760-b531-9767c2e6d322_217609"
]
},
{
"players": [
"2aefcb01-fe81-4760-b531-9767c2e6d322_216386"
]
},
{
"players": [
"2aefcb01-fe81-4760-b531-9767c2e6d322_217008",
"2aefcb01-fe81-4760-b531-9767c2e6d322_217628"
]
}
]
}
推荐答案
Jolt Spec Solution
[
{
"operation": "shift",
"spec": {
"studentEligibility": {
"sportsEligibility": {
"cricketEligibility": {
"*": {
"group": {
"*": "teams[].players[]"
}
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"teams": {
"*": {
"players": {
"*": {
"multiPlayGame": "team.players[]"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"team": {
"players": {
"*": {
"*": {
"studentId": "team[&2].players[]"
}
}
}
}
}
}
]
这篇关于无法使用 jolt 转换在 json 下转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文