json recursion problem

input
{
"tasks": [
{
"name": "task1",
"resources": [
{"cpu": 10, "memory": 5, "storage": 100},
{"cpu": 15, "memory": 15, "storage": 120},
{"cpu": 1, "memory": 50, "storage": 150},
],
"cluster": {"id": "12345", "name": "cluster-12345"}
},
{
"name": "task2",
"resources": [
{"cpu": 11, "memory": 25, "storage": 10},
{"cpu": 12, "memory": 51, "storage": 20},
{"cpu": 11, "memory": 15, "storage": 50},
],
"cluster": {"id": "54321", "name": "cluster-54321"}
}
]
}

expected output

[
{
"tasks_name": "task1",
"tasks_resources_cpu": 10,
"tasks_resources_memory": 5,
"tasks_resources_storage": 100,
"tasks_cluster_id": "12345",
"tasks_cluster_name": "cluster-12345"
},
{
"tasks_name": "task1",
"tasks_resources_cpu": 15,
"tasks_resources_memory": 15,
"tasks_resources_storage": 120,
"tasks_cluster_id": "12345",
"tasks_cluster_name": "cluster-12345"
},
.....
]

Questions: What will be the solution to get output from the given input above without using pandas or pyspark explode method?

Comments (0)