Skip to main content
Drew33
Silver ⭐️
Apr 20, 2024 3:18 AM UTC
Solved

Help with JOLT Spec to add new json key with a value from another key

Hoping someone can help me with a JOLT spec.

 

I have the following json:

{
"schemaVersion": "3.2",
"uniqueIdentifier": "ri.nzRNR5a3ad1AzOkv_2FU9WN6Z_2FluxpEl4eXjgUnYpgkvk_3D",
"entityType": "CAR"
}
 
and I need to use JOLT to transform to this:
 
{
"_id": "ri.nzRNR5a3ad1AzOkv_2FU9WN6Z_2FluxpEl4eXjgUnYpgkvk_3D",
"schemaVersion": "3.2",
"uniqueIdentifier": "ri.nzRNR5a3ad1AzOkv_2FU9WN6Z_2FluxpEl4eXjgUnYpgkvk_3D",
"entityType": "CAR"
}
 
I cannot figure out the correct spec.
 
Thanks!
SAMSAL
SAMSALAnswer
Platinum ⭐️⭐️⭐️
Apr 20, 2024 3:30 AM UTC

Hi,

You can do this in different ways , here is one of them:

[
{
"operation": "shift",
"spec": {
"@uniqueIdentifier": "_id",
"*": "&"
}
}
]

Hope that helps.

 

2 replies

SAMSAL
SAMSALAnswer
Platinum ⭐️⭐️⭐️
Apr 20, 2024 3:30 AM UTC

Hi,

You can do this in different ways , here is one of them:

[
{
"operation": "shift",
"spec": {
"@uniqueIdentifier": "_id",
"*": "&"
}
}
]

Hope that helps.

 

Translate
Drew33
Drew33Author
Silver ⭐️
Apr 20, 2024 12:55 PM UTC

Thank you so much - that worked perfectly.  I have so much to learn about JOLT.

Translate