我正在尝试为下面的输入 json 编写一个 Jolt Transformation。
{
"templateLanguage": "FREEMARKER",
"outputFormat": "JSON",
"templateName": "MPX",
"data": {
"DSID": "36455-001",
"media": {
"subtitle": [
{
"fileName": "Tiger_s_Apprentice_The_caption_5005141918_202401030424.vtt",
"filePath": "ingest/viacom/paramountdvhdrsdr/8100132118",
"materialSubType": "Feature",
"locale": "es-419"
}
],
"caption": [
{
"fileName": "Tiger_s_Apprentice_The_36455_001_FTR_CCAP_T3092_Closed_Caption_SCC_2398_engCC_5005136914_202401030425.scc",
"filePath": "ingest/viacom/paramountdvhdrsdr/8100132118",
"materialSubType": "Feature",
"locale": "en-US"
}
],
"audio": [
{
"fileName": "Tiger_s_Apprentice_The_36455_001_FTR_AOUTPUT_A4970_Audio_BWF_2398_5_1_Interleaved_engAU_5005143352.wav",
"channels": "6",
"filePath": "ingest/viacom/paramountdvhdrsdr/8100132118",
"materialSubType": "Feature",
"locale": "en-US",
"type": "5.1 Surround"
},
{
"dvs": true,
"fileName": "Tiger_s_Apprentice_The_36455_001_FTR_AOUTPUT_A4964_Audio_BWF_2398_2_0_Interleaved_engAU_5005143913.wav",
"channels": "2",
"filePath": "ingest/viacom/paramountdvhdrsdr/8100132118",
"materialSubType": "Feature",
"locale": "en-US",
"type": "2.0 Stereo (L/R)"
}
]
}
}
}
输出 JSON 应如下所示:
{
"videos":[{
"textTracks" : [ {
"techSpec" : {
"type" : "subtitle",
"locale" : "es-419",
"filePath" : "ingest/viacom/paramountdvhdrsdr/8100132118"
},
"fileName" : "Tiger_s_Apprentice_The_caption_5005141918_202401030424.vtt"
},
{
"techSpec" : {
"type" : "caption",
"locale" : "es-US",
"filePath" : "ingest/viacom/paramountdvhdrsdr/8100132118"
},
"fileName" : "Tiger_s_Apprentice_The_36455_001_FTR_CCAP_T3092_Closed_Caption_SCC_2398_engCC_5005136914_202401030425.scc"
}
],
"audios" : [ {
"fileName" : "Tiger_s_Apprentice_The_36455_001_FTR_AOUTPUT_A4970_Audio_BWF_2398_5_1_Interleaved_engAU_5005143352.wav",
"techSpec" : {
"locale" : "en-US",
"filePath" : "ingest/viacom/paramountdvhdrsdr/8100132118",
"materialSubType" : "Feature",
"type" : "5.1 Surround"
}
}, {
"fileName" : "Tiger_s_Apprentice_The_36455_001_FTR_AOUTPUT_A4964_Audio_BWF_2398_2_0_Interleaved_engAU_5005143913.wav",
"techSpec" : {
"locale" : "en-US",
"dvs" : true,
"filePath" : "ingest/viacom/paramountdvhdrsdr/8100132118",
"materialSubType" : "Feature",
"type" : "2.0 Stereo (L/R)"
}
} ],
"mediaMetadata" : [ {
"fileName" : "Tiger_s_Apprentice_The_36455_001_FTR_DOC_Document_Color_Spec_16x9LB_engPT_5005134061.xml",
"techSpec" : {
"filePath" : "ingest/viacom/paramountdvhdrsdr/8100132118"
}
} ]
}]
}
我尝试了以下 Jolt Spec,但它没有按预期工作。
[{
"operation": "shift",
"spec": {
"data": {
"media": {
"thumbnail": {
"*": {
"fileName": "images[&1].fileName",
"filePath": "images[&1].techSpec.filePath"
}
},
"subtitle": {
"*": {
"fileName": "textTracks[&1].fileName",
"#subtitle": "textTracks[&1].techSpec.type",
"locale": "textTracks[&1].techSpec.locale",
"filePath": "textTracks[&1].techSpec.filePath"
}
},
"caption": {
"*": {
"fileName": "textTracks[&2].fileName",
"#caption": "textTracks[&2].techSpec.type",
"locale": "textTracks[&2].techSpec.locale",
"filePath": "textTracks[&2].techSpec.filePath"
}
}
}
}
}
}]
我尝试更改我的 Jolt 规格,但视频作为外部数组和带有字幕和标题的文本轨道作为不同对象无法按预期工作。
您可以使用以下 shift 转换:
[ // accumulate subtitle and caption objects into the common object
{
"operation": "shift",
"spec": {
"data": {
"media": {
"subtitle|caption": { // make the node common by prefixing them as "sc"
"*": {
"fileName": "sc.textTracks.&",
"$1": "sc.textTracks.techSpec[&1].type",
"locale|filePath": "sc.textTracks.techSpec[&1].&"
}
},
"audio": {
"*": {
"fileName": "&2s[&1].&", // prefix sub-elements by audios through
// use of &2 and the letter s
"locale|filePath|*ype": "&2s[&1].techSpec.&"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"sc": { // loop through all sc in order to separate the components of the
// arrays into different objects respectively by the index values
// of those arrays such as 0,1..
"*": {
"*": {
"*": {
"*": {
"*": {
"@": "videos[0].&5.&4.[&1].&2"
}
}
}
}
}
},
"*": "videos[0].&"
}
}
]