вот образец JSON. DW 2.0 преобразование логи c, которое я пробовал, а также ожидаемое xml приведено ниже. Проблема в том, что все эпизоды каждого сезона включаются. > Business logi c: у каждого 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>