I'm trying to transform a record json into individual json records but have a hard time getting the values rather than the names. I expect the keys to change on occasion and there to be more than 4 records on occasion so I wanted it to be dynamic. It seems the current transform will only give me the keys and not the values broken out into there own records.
Input
[
{
"Owner": {
"0": "CIMections",
"1": "CIMections",
"2": "CIMections",
"3": "CIMections"
},
"Name": {
"0": "AFE 20NSF044",
"1": "AFE 20NSF044",
"2": "AFE 20NSF044",
"3": "AFE 20NSF044"
},
"Producer": {
"0": "Produtream",
"1": "Produtream",
"2": "Produtream",
"3": "Produtream"
},
"Producers ID": {
"0": "NTI XR 001-004",
"1": "NTI XR 001-004",
"2": "NTI XR 001-004",
"3": "NTI XR 001-004"
},
"Weld - Real Time Count": {
"0": "",
"1": "",
"2": "",
"3": ""
},
"Character Set": {
"0": "ISO_IR 192",
"1": "ISO_IR 192",
"2": "ISO_IR 192",
"3": "ISO_IR 192"
},
"inv# Welds": {
"0": "Accepted 001",
"1": "Accepted 002",
"2": "Accepted 003",
"3": "Accepted 004"
},
"invoice": {
"0": 893300361,
"1": 411904740,
"2": 673190473,
"3": 1426231494
},
"status": {
"0": "Done",
"1": "Done",
"2": "Done",
"3": "Done"
},
"Date Completed": {
"0": "20210301 163500.000000",
"1": "20210301 163500.000000",
"2": "20210301 163500.000000",
"3": "20210301 163500.000000"
},
"Institution Name": {
"0": "NXXT Digital",
"1": "NXXT Digital",
"2": "NXXT Digital",
"3": "NXXT Digital"
},
"file_id": {
"0": "00001",
"1": "00002",
"2": "00003",
"3": "00004"
}
}
]
Current Transformation
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"Owner": "Owner.[].@(1,0)",
"$": "&",
"@": "@clientId"
}
}
}
}
]
Im Getting
{
"Owner" : "Owner",
"Name" : "Name",
"Producer" : "Producer",
"Producers ID" : "Producers ID",
"Weld - Real Time Count" : "Weld - Real Time Count",
"Character Set" : "Character Set",
"inv# Welds" : "inv# Welds",
"invoice" : "invoice",
"status" : "status",
"Date Completed" : "Date Completed",
"Institution Name" : "Institution Name",
"file_id" : "file_id"
}
But wanting
{
"Owner" : "CIMections",
"Name" : "AFE 20NSF044",
"Producer" : "Produtream",
"Producers ID" : "NTI XR 001-004",
"Weld - Real Time Count" : "",
"Character Set" : "ISO_IR 192",
"inv# Welds" : "Accepted 001",
"invoice" : "893300361",
"status" : "Done",
"Date Completed" : "20210301 163500.000000",
"Institution Name" : "NXXT Digital",
"file_id" : "00001"
},
{
"Owner" : "CIMections",
"Name" : "AFE 20NSF044",
"Producer" : "Produtream",
"Producers ID" : "NTI XR 001-004",
"Weld - Real Time Count" : "",
"Character Set" : "ISO_I 192",
"inv# Welds" : "Accepted 002",
"invoice" : "411904740",
"status" : "Done",
"Date Completed" : "20210301 163500.000000",
"Institution Name" : "NXXT Digital",
"file_id" : "00002"
}...
$
wildcard is not needed, but only using @
wildcard is enough, along with filtering by indices with 0
and 1
(0|1
) such as
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"0|1": {
"@": "[&].&2"
}
}
}
}
}
]
where prepending the value with [&].
converts each individual array to seperate objects within a single array.
If you need to get all the objects within the array, then replace "0|1"
with "*"
wildcard.