Member since
12-18-2024
4
Posts
1
Kudos Received
0
Solutions
12-19-2024
09:23 PM
1 Kudo
Hi @SAMSAL , This works really fine. Thank you so much for your solution. I got your idea of splitting the JSON and perform the transformation in SQL table. I will work on that. Thank you again.
... View more
12-19-2024
05:44 PM
Hi @SAMSAL , Thank you, this JSON is for Bill Of Materials and we have to flatten the entire array at each node and repeat the array values to other columns.
... View more
12-18-2024
03:31 PM
Hi Everyone,
I have the below Input JSON and would like to flatten the data into the below mentioned output JSON format. I am new to the JOLT, I tried to transform (its incomplete) but could not achieve the result.
Kindly help me to get the desired output, thanks in advance.
Input JSON:
{
"data": {
"getItemListing": {
"edges": [
{
"node": {
"id": "2940126",
"identifier": 3119650,
"parentItems": [
{
"id": "364270",
"parentIdentifier": 371153
},
{
"id": "364258",
"parentIdentifier": 371147
}
],
"treatmentClusterIds": [
{
"metadata": [
{
"treatmentClusterIDs": "528"
}
],
"element": {
"name": "GOAT02",
"labelingClusters": [
{
"labelingCluster": "1000"
}
]
}
},
{
"metadata": [
{
"treatmentClusterIDs": "529"
}
],
"element": {
"name": "GOAT03",
"labelingClusters": [
{
"labelingCluster": "4045"
}
]
}
},
{
"metadata": [
{
"treatmentClusterIDs": "5581"
}
],
"element": {
"name": "GOAT04",
"labelingClusters": [
{
"labelingCluster": "2000"
},
{
"labelingCluster": "3000"
},
{
"labelingCluster": "4000"
}
]
}
}
]
}
},
{
"node": {
"id": "2940127",
"identifier": 3119651,
"parentItems": [
{
"id": "364270",
"parentIdentifier": 371154
}
],
"treatmentClusterIds": [
{
"metadata": [
{
"treatmentClusterIDs": "527"
}
],
"element": {
"name": "GOAT01",
"labelingClusters": [
{
"labelingCluster": "1000"
},
{
"labelingCluster": "4045"
},
{
"labelingCluster": "2000"
},
{
"labelingCluster": "3000"
},
{
"labelingCluster": "4000"
}
]
}
}
]
}
}
]
}
}
}
Output JSON:
[ {
"identifier": "3119650",
"parentIdentifier": "371153",
"Element" : "GOAT02",
"TreatmentId" : "528",
"LabelingCluster" : "1000"
}, {
"identifier": "3119650",
"parentIdentifier": "371153",
"Element" : "GOAT03",
"TreatmentId" : "529",
"LabelingCluster" : "4045"
}, {
"identifier": "3119650",
"parentIdentifier": "371153",
"Element" : "GOAT04",
"TreatmentId" : "5581",
"LabelingCluster" : "2000"
}, {
"identifier": "3119650",
"parentIdentifier": "371153",
"Element" : "GOAT04",
"TreatmentId" : "5581",
"LabelingCluster" : "3000"
}, {
"identifier": "3119650",
"parentIdentifier": "371153",
"Element" : "GOAT04",
"TreatmentId" : "5581",
"LabelingCluster" : "4000"
}, {
"identifier": "3119650",
"parentIdentifier": "371147",
"Element" : "GOAT02",
"TreatmentId" : "528",
"LabelingCluster" : "1000"
}, {
"identifier": "3119650",
"parentIdentifier": "371147",
"Element" : "GOAT03",
"TreatmentId" : "529",
"LabelingCluster" : "4045"
}, {
"identifier": "3119650",
"parentIdentifier": "371147",
"Element" : "GOAT04",
"TreatmentId" : "5581",
"LabelingCluster" : "2000"
}, {
"identifier": "3119650",
"parentIdentifier": "371147",
"Element" : "GOAT04",
"TreatmentId" : "5581",
"LabelingCluster" : "3000"
}, {
"identifier": "300119650",
"parentIdentifier": "371147",
"Element" : "GOAT04",
"TreatmentId" : "5581",
"LabelingCluster" : "4000"
}, {
"identifier": "3119651",
"parentIdentifier": "371154",
"Element" : "GOAT01",
"TreatmentId" : "527",
"LabelingCluster" : "1000"
}, {
"identifier": "3119651",
"parentIdentifier": "371154",
"Element" : "GOAT01",
"TreatmentId" : "527",
"LabelingCluster" : "4045"
}, {
"identifier": "3119651",
"parentIdentifier": "371154",
"Element" : "GOAT01",
"TreatmentId" : "527",
"LabelingCluster" : "2000"
}, {
"identifier": "3119651",
"parentIdentifier": "371154",
"Element" : "GOAT01",
"TreatmentId" : "527",
"LabelingCluster" : "3000"
}, {
"identifier": "3119651",
"parentIdentifier": "371154",
"Element" : "GOAT01",
"TreatmentId" : "527",
"LabelingCluster" : "4000"
} ]
JOLT spec I tired (incomplete):
[
{
"operation": "shift",
"spec": {
"data": {
"getItemListing": {
"edges": {
"*": {
"node": {
"treatmentClusterIds": {
"*": "[]"
}
}
}
}
}
}
}
}, {
"operation": "shift",
"spec": {
"*": {
"element": {
"labelingClusters": {
"*": {
"labelingCluster": "[&4].[&1].LabelingCluster",
"@(2,name)": "[&4].[&1].Element",
"@3,metadata": {
"*": {
"treatmentClusterIDs": "[&6].[&2].TreatmentId"
}
}
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": "[]"
}
}
}
]
... View more
Labels:
- Labels:
-
Apache NiFi