mulesoft - Mule 4/DW 2.0 - 在地图内循环出现问题
问题描述
这是示例 JSON。我尝试的 DW 2.0 转换逻辑以及预期的 xml 如下所示。问题是 - 每个季节下的所有剧集都被包括在内。>业务逻辑:每个show_id有多个系列,每个系列有多个季节,每个季节有多个剧集。如果需要任何其他详细信息,请告诉我。
输入 JSON : >输入是一个 JSON 对象数组
[
{
"uniqueid": "(ASSSIM0001,Simulcast,English)",
"genres": "Action/Adventure,Comedy,Sci Fi",
"quality_quality": "HD",
"show_detail_box_art_phone":
"season_sequence_number": "1",
"videos_id": "74052",
"videos_ratings": "PS-RTE,14-TV-US,14-CBSC,12-zw-movies",
"show_id": "ASS",
"videos_alpha_external_id": "ASSSIM0001",
"purchase_type": "AVOD",
"territory": "Canada - English speaking",
"videos_episode_number": "1 ",
"series_name": "Assassination Classroom",
"title": "Assassination Time English Simulcast",
"title_category": "Episode",
"episode_id": "19467"
},
{
"uniqueid": "(ASSSIM0001,Simulcast,Japanese)",
"genres": "Action/Adventure,Comedy,Sci Fi",
"quality_quality": "HD",
"show_detail_box_art_phone":
"season_sequence_number": "1",
"videos_id": "19468",
"videos_ratings": "PS-RTE,14-TV-US,14-CBSC,12-zw-movies",
"show_id": "ASS",
"videos_alpha_external_id": "ASSSIM0001",
"purchase_type": "SVOD",
"territory": "Canada - English speaking",
"videos_episode_number": "1 ",
"series_name": "Assassination Classroom",
"title": "Assassination Time Japanese Simulcast",
"title_category": "Episode",
"episode_id": "19467"
},
{
"uniqueid": "(ASSSIM0023,Simulcast,English)",
"genres": "Action/Adventure,Comedy,Sci Fi",
"quality_quality": "HD",
"show_detail_box_art_phone":
"season_sequence_number": "2",
"videos_id": "91325",
"videos_ratings": "14-TV-US,PS-RTE,14-CBSC,12-zw-movies",
"show_id": "ASS",
"videos_alpha_external_id": "ASSSIM0023",
"purchase_type": "AVOD",
"territory": "Canada - English speaking",
"firstname_lastname_charactername_spokenlanguage": "",
"videos_episode_number": "23 ",
"series_name": "Assassination Classroom",
"title": "Summer Festival Time English Simulcast",
"title_category": "Episode",
"firstname_lastname_capacity_spokenlanguage": "",
"episode_id": "91324"
},
{
"uniqueid": "(ASSSIM0023,Simulcast,Japanese)",
"genres": "Action/Adventure,Comedy,Sci Fi",
"quality_quality": "HD",
"show_detail_box_art_phone":
"season_sequence_number": "2",
"videos_id": "91350",
"videos_ratings": "14-TV-US,PS-RTE,14-CBSC,12-zw-movies",
"show_id": "ASS",
"videos_alpha_external_id": "ASSSIM0023",
"purchase_type": "AVOD",
"territory": "Canada - English speaking",
"firstname_lastname_charactername_spokenlanguage": "",
"videos_episode_number": "23 ",
"series_name": "Assassination Classroom",
"title": "Summer Festival Time Japanese Simulcast",
"title_category": "Episode",
"firstname_lastname_capacity_spokenlanguage": "",
"episode_id": "91324"
}
]
DW 2.0 代码:
%dw 2.0
output application/xml
---
partnerContent: {
seriesItems: {
series: (payload distinctBy $.show_id map(( seriesitems , seriesindex ) -> {
titles: {
title: seriesitems.series_name
},
descriptions: {
description: seriesitems.series_short_synopsis
}
,
seasons1: {
season:
(payload distinctBy $.season_sequence_number map ( seasons , seasonsindex ) -> {
seasonNumber: seasons.season_sequence_number,
episodes1: {
(payload distinctBy $.videos_id map ( episodes , episodeindex ) -> {
episode @(id: episodes.videos_id): {
titles: {
title @(language: 'en'): episodes.title
},
descriptions: {
description: episodes.title_short_synopsis
},
episodeNumber: trim(episodes.videos_episode_number)
}
})
}
})
}
}))
}
}
当前输出 xml:当前生成的 xml 打印了 2 个季节中的每个季节的所有剧集
<?xml version='1.0' encoding='UTF-8'?>
<partnerContent>
<seriesItems>
<series>
<titles>
<title>Assassination Classroom</title>
</titles>
<descriptions>
<description>Forget about homework and pop quizzes Class 3E has a far more important assignment kill their teacher before the end of the year </description>
</descriptions>
<seasons1>
<season>
<seasonNumber>1</seasonNumber>
<episodes1>
<episode id="74052">
<titles>
<title language="en">Assassination Time English Simulcast</title>
</titles>
<descriptions>
<description>A creature who blasted the moon into a crescent shows up at Kunugigaoka Junior High School and he s giving the students a year to assassinate him </description>
</descriptions>
<episodeNumber>1</episodeNumber>
</episode>
<episode id="19468">
<titles>
<title language="en">Assassination Time Japanese Simulcast</title>
</titles>
<descriptions>
<description>A creature who blasted the moon into a crescent shows up at Kunugigaoka Junior High School and he s giving the students a year to assassinate him </description>
</descriptions>
<episodeNumber>1</episodeNumber>
</episode>
<episode id="91325">
<titles>
<title language="en">Summer Festival Time English Simulcast</title>
</titles>
<descriptions>
<description>Koro Sensei and his students try some matchmaking at the end of their island trip Class 3 E s eventful summer ends with a taste of pure festival fun </description>
</descriptions>
<episodeNumber>23</episodeNumber>
</episode>
<episode id="91350">
<titles>
<title language="en">Summer Festival Time Japanese Simulcast</title>
</titles>
<descriptions>
<description>Koro Sensei and his students try some matchmaking at the end of their island trip Class 3 E s eventful summer ends with a taste of pure festival fun </description>
</descriptions>
<episodeNumber>23</episodeNumber>
</episode>
</episodes1>
</season>
<season>
<seasonNumber>2</seasonNumber>
<episodes1>
<episode id="74052">
<titles>
<title language="en">Assassination Time English Simulcast</title>
</titles>
<descriptions>
<description>A creature who blasted the moon into a crescent shows up at Kunugigaoka Junior High School and he s giving the students a year to assassinate him </description>
</descriptions>
<episodeNumber>1</episodeNumber>
</episode>
<episode id="19468">
<titles>
<title language="en">Assassination Time Japanese Simulcast</title>
</titles>
<descriptions>
<description>A creature who blasted the moon into a crescent shows up at Kunugigaoka Junior High School and he s giving the students a year to assassinate him </description>
</descriptions>
<episodeNumber>1</episodeNumber>
</episode>
<episode id="91325">
<titles>
<title language="en">Summer Festival Time English Simulcast</title>
</titles>
<descriptions>
<description>Koro Sensei and his students try some matchmaking at the end of their island trip Class 3 E s eventful summer ends with a taste of pure festival fun </description>
</descriptions>
<episodeNumber>23</episodeNumber>
</episode>
<episode id="91350">
<titles>
<title language="en">Summer Festival Time Japanese Simulcast</title>
</titles>
<descriptions>
<description>Koro Sensei and his students try some matchmaking at the end of their island trip Class 3 E s eventful summer ends with a taste of pure festival fun </description>
</descriptions>
<episodeNumber>23</episodeNumber>
</episode>
</episodes1>
</season>
</seasons1>
</series>
</seriesItems>
</partnerContent>
-------------End of current output xml--------------------------
**Expected output xml**: >*Expected output xml is to show only the first 2 Episodes data in Season 1
and last 2 Episodes under Season 2*
------------------------Start of Expected output xml--------------------------------------
<?xml version='1.0' encoding='UTF-8'?>
<partnerContent>
<seriesItems>
<series>
<titles>
<title>Assassination Classroom</title>
</titles>
<descriptions>
<description>Forget about homework and pop quizzes Class 3E has a far more important assignment kill their teacher before the end of the year </description>
</descriptions>
<seasons1>
<season>
<seasonNumber>1</seasonNumber>
<episodes1>
<episode id="74052">
<titles>
<title language="en">Assassination Time English Simulcast</title>
</titles>
<descriptions>
<description>A creature who blasted the moon into a crescent shows up at Kunugigaoka Junior High School and he s giving the students a year to assassinate him </description>
</descriptions>
<episodeNumber>1</episodeNumber>
</episode>
<episode id="19468">
<titles>
<title language="en">Assassination Time Japanese Simulcast</title>
</titles>
<descriptions>
<description>A creature who blasted the moon into a crescent shows up at Kunugigaoka Junior High School and he s giving the students a year to assassinate him </description>
</descriptions>
<episodeNumber>1</episodeNumber>
</episode>
</episodes1>
</season>
<season>
<seasonNumber>2</seasonNumber>
<episodes1>
<episode id="91325">
<titles>
<title language="en">Summer Festival Time English Simulcast</title>
</titles>
<descriptions>
<description>Koro Sensei and his students try some matchmaking at the end of their island trip Class 3 E s eventful summer ends with a taste of pure festival fun </description>
</descriptions>
<episodeNumber>23</episodeNumber>
</episode>
<episode id="91350">
<titles>
<title language="en">Summer Festival Time Japanese Simulcast</title>
</titles>
<descriptions>
<description>Koro Sensei and his students try some matchmaking at the end of their island trip Class 3 E s eventful summer ends with a taste of pure festival fun </description>
</descriptions>
<episodeNumber>23</episodeNumber>
</episode>
</episodes1>
</season>
</seasons1>
</series>
</seriesItems>
</partnerContent>
解决方案
什么是预期的输出?哪些元素不应该包含在输出中?
推荐阅读
- nlp - GCP AutoML Natural Language 中 Word Boundary 的 PDF 标注问题
- git - 分支和拉取请求在 SonarQube 仪表板中不可见?
- video-streaming - Bananapi M3:GStreamer 无法分配缓冲区大小
- sdk - 在 cognos 平台 java sdk 中有没有办法直接从管理员登录查询用户特定报告?
- amazon-redshift - 架构和表的 AWS Redshift 列表以及组名
- python - 读取包含存储为 numpy 数组的图像的 hdf5 文件的最有效方法是什么?
- java - 无法在 Android Studio 中获取对 Firebase 中自动生成的密钥的引用
- swift - 显式添加对闭包捕获的引用
- .net - EF Core 跟踪的实体未保存
- swift - CurrentValueSubject 的订阅者如何捕获错误