Here is the sample input JSON: *
[
{
"animation_production_studios": [],
"audio": [
"English",
"Japanese"
],
"videos": [
{
"DASH": true,
"aips": [
400,
824,
1191
],
},
{
"DASH": true,
"aips": [
401,
825,
1192
],
}
]
]
},
{
"animation_production_studios": ["Studio Chizu"],
"audio": [
"English",
"Japanese"
],
"videos": [
{
"DASH": true,
"aips": [
403,
826,
1193
],
},
{
"DASH": true,
"aips": [
404,
827,
1194
],
}
]
]
}
]
*
Here is the expected output (to be able to insert into a db as below):
animation_production_studios audio videos_dash videos_aips
------------------------------------------------------------------------------------
Null English, Japanese true 400, 824, 1191
Null English, Japanese true 401, 825, 1192
Studio Chizu English, Japanese true 402, 826, 1193
Studio Chizu English, Japanese true 403, 827, 1194
Here is the DW%2.0 code I tried:
payload map(item, index) -> {
(item.videos map(viditem, vidindex)) -> {
videos_aips: (viditem.videos map ((vitem, vindex) ->
vitem.aips reduce ((vi, vacc) -> vacc + vi )))[0],
show_id: item."show_id",
audio: (payload map ((aitem, aindex) -> item.audio
reduce ((i, acc) -> acc ++ "," ++ i )))[0]
}
}
Throwing an error:
(item.videos map(viditem, vidindex)) -> {
^
Invalid input ',', expected ')' for the enclosed expression.