🐧 Linux TippsGitHub Release: ddev/ddev v1.25.4 (04.09.2026)(04.09.2026 um 20:07 Uhr)
🔧 ProgrammierungGitHub Release: rust-lang/rust v1.98.1 (03.09.2026)(03.09.2026 um 15:14 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.1 (11.09.2026)(11.09.2026 um 05:17 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.2 (11.09.2026)(11.09.2026 um 06:11 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.3 (11.09.2026)(11.09.2026 um 06:23 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.4 (11.09.2026)(11.09.2026 um 06:44 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.5 (11.09.2026)(11.09.2026 um 07:07 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.6 (11.09.2026)(11.09.2026 um 08:08 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.7 (11.09.2026)(11.09.2026 um 10:17 Uhr)
🐧 Linux TippsGitHub Release: ddev/ddev v1.25.4 (04.09.2026)(04.09.2026 um 20:07 Uhr)
🔧 ProgrammierungGitHub Release: rust-lang/rust v1.98.1 (03.09.2026)(03.09.2026 um 15:14 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.1 (11.09.2026)(11.09.2026 um 05:17 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.2 (11.09.2026)(11.09.2026 um 06:11 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.3 (11.09.2026)(11.09.2026 um 06:23 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.4 (11.09.2026)(11.09.2026 um 06:44 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.5 (11.09.2026)(11.09.2026 um 07:07 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.6 (11.09.2026)(11.09.2026 um 08:08 Uhr)
🔧 AI Nachrichten GitHub Release: openai/codex vrust-v0.155.0-alpha.3.7 (11.09.2026)(11.09.2026 um 10:17 Uhr)

🔧 Programmierung 🕛 vor 1 Jahr 4 Min Lesezeit
0

Mastering JOLT Spec Operations: A Guide with Examples

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

Note: For the practical exposure you can visit below link



https://jolt-demo.appspot.com/#inception



JOLT (JSON to JSON Transformation) is a powerful framework for transforming JSON data. It’s especially useful when dealing with complex transformations such as restructuring, renaming, or removing JSON fields. In this blog, I will walk you through some key JOLT operations and how to use the special operators &, *, @, $, #, along with transformation operations like shift, remove, and cardinality.



To demonstrate these operations, we’ll use the following sample JSON as our input:






Input JSON:






CODE
{
"client": {
"address": {
"street": "11 street cop work",
"state": "New York"
},
"name": "Amazon",
"contact": "001–786543",
"employeeDetails": [
{
"name": "John Green",
"designation": "Software engineer",
"phone": "91–7865432300",
"home": "080–78645–87362",
"address": "11th streem Smt Amest"
},
{
"name": "Dev Axe",
"designation": "Sr. Software engineer",
"phone": "91–7865432900",
"home": "080–78645–89362",
"address": "11th Smt Amest"
}
]
}
}












1. The & Operator: Accessing Indices or Values



The & operator allows you to reference the current index or value when transforming arrays.






Example: Mapping Employee Names with Indices






CODE
[
{
"operation": "shift",
"spec": {
"client": {
"employeeDetails": {
"*": {
"name": "employees[&1].name"
}
}
}
}
}
]









Output:






CODE
{
"employees": [
{ "name": "John Green" },
{ "name": "Dev Axe" }
]
}






In this example, &1 references the index of the current employee in the array.









2. The * Operator: Wildcard Matching



* is a wildcard operator used to match any key or value. This is useful for applying the same transformation to multiple fields or elements.






Example: Shifting Employee Data to a New Structure






CODE
[
{
"operation": "shift",
"spec": {
"client": {
"employeeDetails": {
"*": {
"name": "employees[*].name",
"designation": "employees[*].role"
}
}
}
}
}
]









Output:






CODE
{
"employees": [
{ "name": "John Green", "role": "Software engineer" },
{ "name": "Dev Axe", "role": "Sr. Software engineer" }
]
}






Here, * matches all the employee objects, ensuring each one is transformed into a new structure with the name and role.









3. The @ Operator: Self-Reference



The @ operator lets you refer to the current value being processed. You can use it to copy the entire structure at the current level.






Example: Copying Employee Data into a Separate Field






CODE
[
{
"operation": "shift",
"spec": {
"client": {
"employeeDetails": {
"*": {
"name": "employees[*].name",
"@": "employees[*].originalData"
}
}
}
}
}
]









Output:






CODE
{
"employees": [
{
"name": "John Green",
"originalData": {
"name": "John Green",
"designation": "Software engineer",
"phone": "91–7865432300",
"home": "080–78645–87362",
"address": "11th streem Smt Amest"
}
},
{
"name": "Dev Axe",
"originalData": {
"name": "Dev Axe",
"designation": "Sr. Software engineer",
"phone": "91–7865432900",
"home": "080–78645–89362",
"address": "11th Smt Amest"
}
}
]
}






In this case, @ duplicates the entire employee object into a new field called originalData.









4. The $ Operator: Accessing Root-Level Data



The $ operator gives you access to the root level of the JSON document, allowing you to bring in data from other parts of the document.






Example: Copying Client Contact into Each Employee Record






CODE
[
{
"operation": "shift",
"spec": {
"client": {
"employeeDetails": {
"*": {
"name": "employees[*].name",
"$": {
"client.contact": "employees[*].clientContact"
}
}
}
}
}
}
]









Output:






CODE
{
"employees": [
{ "name": "John Green", "clientContact": "001–786543" },
{ "name": "Dev Axe", "clientContact": "001–786543" }
]
}






The $ operator allows us to access the root level and bring in the client’s contact information for each employee.









5. The # Operator: Inserting Literal Values



With #, you can insert literal values directly into the output, which is useful for providing default values.






Example: Inserting a Default Email for Employees






CODE
[
{
"operation": "shift",
"spec": {
"client": {
"employeeDetails": {
"*": {
"name": "employees[*].name",
"#Not Available": "employees[*].email"
}
}
}
}
}
]









Output:






CODE
{
"employees": [
{ "name": "John Green", "email": "Not Available" },
{ "name": "Dev Axe", "email": "Not Available" }
]
}






Here, #Not Available adds the literal string "Not Available" for employees who don’t have an email field.









6. Shift Operation: Restructuring JSON



The shift operation is one of the most commonly used transformations. It allows you to move data to new keys or structures.






Example: Restructuring Employee Data






CODE
[
{
"operation": "shift",
"spec": {
"client": {
"employeeDetails": {
"*": {
"name": "transformedEmployees[*].fullName",
"designation": "transformedEmployees[*].jobTitle"
}
}
}
}
}
]









Output:






CODE
{
"transformedEmployees": [
{ "fullName": "John Green", "jobTitle": "Software engineer" },
{ "fullName": "Dev Axe", "jobTitle": "Sr. Software engineer" }
]
}






The shift operation moves the employee details into a new key (transformedEmployees).









7. Remove Operation: Deleting Data



The remove operation helps you eliminate unwanted fields from your JSON.






Example: Removing Sensitive Employee Data






CODE
[
{
"operation": "remove",
"spec": {
"client": {
"employeeDetails": {
"*": {
"home": ""
}
}
}
}
}
]









Output:






CODE
{
"client": {
"employeeDetails": [
{
"name": "John Green",
"designation": "Software engineer",
"phone": "91–7865432300",
"address": "11th streem Smt Amest"
}
]
}
}






The home field has been removed from each employee’s contact details.









8. Cardinality: Converting Arrays to Objects



The cardinality operation allows you to change how arrays are represented. You can collapse arrays with a single item into objects.






Example: Converting Employee Array to Single Object






CODE
[
{
"operation": "cardinality",
"spec": {
"client": {
"employeeDetails": "ONE"
}
}
}
]









Output (if there is only one employee):






CODE
{
"client": {
"employeeDetails": {
"name": "John Green",
"designation": "Software engineer",
"phone": "91–7865432300",
"home": "080–78645–87362",
"address": "11th streem Smt Amest"
}
}
}






This collapses the employeeDetails array into a single object if it contains only one employee.









Conclusion



The JOLT framework provides a wide range of powerful transformations for working with JSON data. Whether you need to restructure data, remove sensitive fields, or insert default values, these operations allow you to make quick, effective changes.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
15 Quellen
GitHub Release: ddev/ddev v1.25.4 (04.09.2026)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Mastering JOLT Spec Operations: A Guide with Examples

Thematisch verwandte Begriffe: Mastering, JOLT, Spec, Operations · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...