0
I have a json which contains categories and subcategories, I would like to transform it using Jolt.
Thereof:
[
{
"id": 1,
"name": "Alimentos",
"children": [
{
"id": 2,
"name": "Arroz"
},
{
"id": 3,
"name": "Azeites"
}
]
},
{
"id": 4,
"name": "Beleza e Higiene",
"children": [
{
"id": 5,
"name": "Óleos essenciais"
},
{
"id": 6,
"name": "Sabonetes"
}
]
}
]
For that reason:
[
{
"id": 1,
"name": "Alimentos",
"parent_id": 0
},
{
"id": 2,
"name": "Arroz",
"parent_id": 1
},
{
"id": 3,
"name": "Azeites",
"parent_id": 1
},
{
"id": 4,
"name": "Beleza e Higiene",
"parent_id": 0
},
{
"id": 5,
"name": "Óleos essenciais",
"parent_id": 4
},
{
"id": 6,
"name": "Sabonetes",
"parent_id": 4
}
]
Trying:
[
{
"operation": "shift",
"spec": {
"*": {
"id": "categories.@(1,id).category_id",
"name": "categories.@(1,id).name",
"children": {
"*": {
"id": "categories.@(1,id).category_id",
"name": "categories.@(1,id).name"
}
}
}
}
}
]
What is Jolt? Could you put one of your attempts to the question?
– Woss
https://github.com/bazaarvoice/jolt
– André Luis