本文介绍了无法使用Jolt转换将其转换为以下格式的json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
无法使用jolt来实现上述输出格式,并且经历了多个SO问题,并且找不到类似的问题.尝试在jolt spec数组中添加索引,但是没有用.在此先感谢您,并在下面找到输入,输出和震动规格
Unable to achieve above output format using jolt and gone through multiple SO questions and could not find similar one. Tried with adding indexes inside array of jolt spec but did not work.Thanks in Advance and find the input, output and jolt spec at below
输入:
{
"test1": "Student",
"School": {
"Syllabus": {
"Midterm": {
"inclusions": {
"includedSubjectsList": {
"Subjects": [
{
"subjectName": "MH1"
},
{
"subjectName": "MH2"
},
{
"subjectName": "MH3"
},
{
"subjectName": "MH4"
}
]
}
}
}
}
}
}
Jolt Spec:
[
{
"operation": "shift",
"spec": {
"School": {
"Syllabus": {
"Midterm": {
"inclusions": {
"includedSubjectsList": {
"Subjects": {
"*": {
"subjectName": "Academy[].books[]"
}
}
}
}
}
}
}
}
}
]
当前输出:
{
"Academy" : [ {
"books" : [ "MH1" ]
}, {
"books" : [ "MH2" ]
}, {
"books" : [ "MH3" ]
}, {
"books" : [ "MH4" ]
} ]
}
预期输出:
{
"Academy" : [
{
"books" : [ "MH1","MH2", "MH3","MH4"]
}
]
}
推荐答案
您几乎是正确的.替换
"subjectName": "Academy[].books[]"
使用
"subjectName": "Academy[0].books[]"
这篇关于无法使用Jolt转换将其转换为以下格式的json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!