From 7e53f6853dc0dbbcbf0d883e3fa9bc672852da67 Mon Sep 17 00:00:00 2001 From: Prakhar Yadav Date: Mon, 22 May 2023 18:47:09 +0530 Subject: [PATCH 1/5] The Jolt Transformation Specs Completed --- Jolt Transformation.json | 2383 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 2383 insertions(+) create mode 100644 Jolt Transformation.json diff --git a/Jolt Transformation.json b/Jolt Transformation.json new file mode 100644 index 00000000..a374b20b --- /dev/null +++ b/Jolt Transformation.json @@ -0,0 +1,2383 @@ +// 1 +// Input JSON +{ + "orders": [ + { + "orderId": 1, + "orderDate": "2022-02-20T12:34:56Z", + "customer": { + "customerId": 1, + "firstName": "John", + "lastName": "Doe", + "email": "johndoe@example.com", + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + } + }, + "items": [ + { + "itemId": 1, + "name": "Product A", + "quantity": 2, + "price": 10.0 + }, + { + "itemId": 2, + "name": "Product B", + "quantity": 1, + "price": 20.0 + } + ] + }, + { + "orderId": 2, + "orderDate": "2022-02-21T09:12:34Z", + "customer": { + "customerId": 2, + "firstName": "Jane", + "lastName": "Smith", + "email": "janesmith@example.com", + "address": { + "street": "456 Oak St", + "city": "Somewhere", + "state": "NY", + "zip": "67890" + } + }, + "items": [ + { + "itemId": 3, + "name": "Product C", + "quantity": 3, + "price": 15.0 + } + ] + } + ] +} +//JSON Spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "orders": { + "*": { + "customer": { + "address": "=concat(@(1,address.street),' ',@(1,address.city), ' ', @(1,address.state), ' ',@(1,address.zip))" + }, + "itemTemp": "@(1,items)" + } + } + } + }, + + { + "operation": "modify-overwrite-beta", + "spec": { + "orders": { + "*": { + "itemTemp": { + "*": { + "inverseValue": "=divide(1,@(1,price))", + "temp": "=divideAndRound(2, @(1,quantity), @(1,inverseValue))" + } + } + } + } + } + }, + { + "operation": "shift", + "spec": { + "orders": { + "*": { + "*": "orders[&1].&", + "itemTemp": { + "*": { + "temp": "orders[#4].total" + } + } + } + } + } + }, + { + "operation": "modify-overwrite-beta", + "spec": { + "orders": { + "*": { + "total": "=doubleSum(@(1,total))" + } + } + } + }, + + { + "operation": "remove", + "spec": { + "orders": { + "*": { + "items": { + "*": { + "inverseValue": "", + "temp": "" + } + } + } + } + } + } +] +//Output JSON +{ + "orders": [ + { + "orderId": 1, + "orderDate": "2022-02-20T12:34:56Z", + "customer": { + "customerId": 1, + "fullName": "John Doe", + "email": "johndoe@example.com", + "address": "123 Main St, Anytown, CA 12345" + }, + "items": [ + { + "itemId": 1, + "name": "Product A", + "quantity": 2, + "price": 10.0 + }, + { + "itemId": 2, + "name": "Product B", + "quantity": 1, + "price": 20.0 + } + ], + "total": 40.0 + }, + { + "orderId": 2, + "orderDate": "2022-02-21T09:12:34Z", + "customer": { + "customerId": 2, + "fullName": "Jane Smith", + "email": "janesmith@example.com", + "address": "456 Oak St, Somewhere, NY 67890" + }, + "items": [ + { + "itemId": 3, + "name": "Product C", + "quantity": 3, + "price": 15.0 + } + ], + "total": 45.0 + } + ] +} + +// 2. +// Input JSON +{ + "name": "John", + "age": 35, + "city": "New York" +} + +// Transformation Jolt +[ + { + "operation": "shift", + "spec": { + "name": "Name", + "age": "Age", + "city": "City" + } + } +] + +// Output JSON +{ + "Name": "John", + "Age": 35, + "City": "New York" +} + + +// 3. +// Input JSON +{ + "name": "John", + "age": 35, + "city": "New York", + "phone": "+1-555-123-4567" +} + +// Transformation Jolt +[ + { + "operation": "shift", + "spec": { + "name": "Name", + "age": "Age", + "city": "City", + "phone": "Phone" + } + } +] + +// Output JSON +{ + "Name": "John", + "Age": 35, + "Contact": { + "City": "New York", + "Phone": "+1-555-123-4567" + } +} +//4 +//Input JSON + +{ + "name": "John", + "age": 35, + "hobbies": [ + "reading", + "movies", + "travel" + ] +} + +//Jolt Spec +[ + { + "operation": "shift", + "spec": { + "name": "Name", + "age": "Age", + "hobbies": { + "*": "Hobbies[&].Name" + } + } + } +] + +//Output JSON +{ + "Name" : "John", + "Age" : 35, + "Hobbies" : [ { + "Name" : "reading" + }, { + "Name" : "movies" + }, { + "Name" : "travel" + } ] +} + +//5 +//Input JSON + +{ + "firstName": "John", + "lastName": "Doe", + "email": "johndoe@example.com", + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + } +} + +// Jolt spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "fullName": "=concat(@(1,firstName),' ',@(1,lastName))" + } + } + , { + "operation": "shift", + "spec": { + "fullName": "&", + "email": "&", + "address": { + "city": "&", + "zip": "&" + } + } + } +] + +// Output JSON +{ + "fullName" : "John Doe", + "email" : "johndoe@example.com", + "city" : "Anytown", + "zip" : "12345" +} + +//6 +// Input JSON +{ + "users": [ + { + "name": "John Doe", + "age": 35, + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + }, + "hobbies": [ + { + "name": "reading", + "type": "indoor" + }, + { + "name": "hiking", + "type": "outdoor" + } + ] + }, + { + "name": "Jane Doe", + "age": 30, + "address": { + "street": "456 First St", + "city": "Othertown", + "state": "NY", + "zip": "67890" + }, + "hobbies": [ + { + "name": "swimming", + "type": "outdoor" + }, + { + "name": "painting", + "type": "indoor" + } + ] + } + ] +} + +// Jolt Spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "users": { + "*": { + "Address": "=concat(@(1,address.street),', ',@(1,address.city),', ',@(1,address.state),', ',@(1,address.zip))" + } + } + } + }, + { + "operation": "shift", + "spec": { + "users": { + "*": { + "name": "[#2].Name", + "Address": "[#2].Address", + "hobbies": { + "*": { + "name": "[#4].Hobbies" + } + } + } + } + } + } +] + +//Output JSON +[ { + "Name" : "John Doe", + "Address" : "123 Main St, Anytown, CA, 12345", + "Hobbies" : [ "reading", "hiking" ] +}, { + "Name" : "Jane Doe", + "Address" : "456 First St, Othertown, NY, 67890", + "Hobbies" : [ "swimming", "painting" ] +} ] + + +//7 +//Input JSON +{ + "students": [ + { + "name": "John Doe", + "age": 23, + "email": "john.doe@example.com" + }, + { + "name": "Jane Smith", + "age": 25, + "email": "jane.smith@example.com" + } + ] +} + +//Jolt Spec +[ + { + "operation": "shift", + "spec": { + "students": { + "*": "[#1]" + } + } + } + , + { + "operation": "modify-overwrite-beta", + "spec": { + "*": { + "Name": "name", + "Age": "age", + "domainTemp": "=split('@',@(1,email))", + "Domain": "=lastElement(@(1,domainTemp))" + } + } + }, + { + "operation": "remove", + "spec": { + "*": { + "name": "", + "age": "", + "email": "", + "domainTemp": "" + } + } + } +] + +//Output JSON +[ { + "Name" : "name", + "Age" : "age", + "Domain" : "example.com" +}, { + "Name" : "name", + "Age" : "age", + "Domain" : "example.com" +} +] + +// 8 +// Input: +{ + "employees": [ + { + "name": "John Doe", + "salary": 50000, + "department": "Sales" + }, + { + "name": "Jane Smith", + "salary": 60000 + }, + { + "name": "Bob Johnson", + "department": "IT" + } + ] +} + + +// Transformation: + +[ + { + "operation": "modify-default-beta", + "spec": { + "employees": { + "[0]": { + "bonus": 1000, + "tempBonus": 1000 + }, + "[1]": { + "bonus": 1500, + "tempBonus": 1500 + }, + "[2]": { + "salary":4500, + "bonus": 900, + "tempBonus": 900 + } + } + } + }, + { + "operation": "shift", + "spec": { + "employees": { + "*": { + "*": "employees[&1].&", + "tempBonus": "totalBonus[]" + } + } + } + }, + { + "operation": "modify-overwrite-beta", + "spec": { + "totalBonus": "=intSum(@(1,totalBonus))" + } + } + + + + + +] + + +// Output: + +{ + "employees" : [ { + "name" : [ "John Doe", "Jane Smith", "Bob Johnson" ] + }, { + "salary" : [ 50000, 60000 ], + "department" : "IT" + }, { + "department" : "Sales", + "bonus" : [ 1500, 900 ] + }, { + "bonus" : 1000 + } ], + "totalBonus" : 3400 +} + +//9 +// Input JSON +{ + "name": "John", + "age": 30, + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + } +} + +//Jolt Spec +[ + { + "operation": "remove", + "spec": { + "address": { + "state": "" + } + } + } +] + +// Output JSON +{ + "name" : "John", + "age" : 30, + "address" : { + "street" : "123 Main St", + "city" : "Anytown", + "zip" : "12345" + } +} + +//10 +// Input JSON +{ + "name": "John Smith", + "age": 35, + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + }, + "phone_numbers": [ + { + "type": "home", + "number": "555-1234" + }, + { + "type": "work", + "number": "555-5678" + } + ] +} + +// Jolt Spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "fullName": "=split(' ',@(2,name))", + "first_name": "=firstElement(@(1,fullName))", + "last_name": "=lastElement(@(1,fullName))", + "phone_number_count": "=size(@(1,phone_numbers))" + } + }, + { + "operation": "shift", + "spec": { + "first_name": "&", + "last_name": "&", + "age": "&", + "address": "&", + "phone_numbers": "&", + "phone_number_count": "&" + } + } + +] + +//Output JSON +{ + "first_name": "John", + "last_name": "Smith", + "age": 35, + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + }, + "phone_numbers": [ + { + "type": "home", + "number": "555-1234" + }, + { + "type": "work", + "number": "555-5678" + } + ], + "phone_number_count": 2 +} + +// 11 +// Input JSON +{ + "items": [ + { + "name": "item1", + "value": 10 + }, + { + "name": "item2", + "value": 20 + } + ] +} + +// Jolt Spec +[ + + { + "operation": "shift", + "spec": { + "items": { + "*": { + "name": "items[#2].itemName", + "value": "items[#2].itemValue" + } + } + } + } + +] + +// Output JSON +{ + "items" : [ { + "itemName" : "item1", + "itemValue" : 10 + }, { + "itemName" : "item2", + "itemValue" : 20 + } ] +} + +// 12 +// Input JSON +{ + "employee": { + "firstName": "John", + "lastName": "Doe", + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + }, + "phones": [ + { + "type": "home", + "number": "555-555-1234" + }, + { + "type": "work", + "number": "555-555-5678" + } + ] + } +} + +// Jolt Spec +[ + + { + "operation": "modify-overwrite-beta", + "spec": { + "employee": { + "name": "=concat(@(1,firstName),' ', @(1,lastName))", + "address": "=concat(@(1,address.street),' ', @(1,address.city),' ', @(1,address.state),' ', @(1,address.zip))" + } + } + }, + { + "operation": "shift", + "spec": { + "employee": { + "name": "name", + "address": "&", + "phones": "phoneNumbers" + } + } + } +] + +// Output JSON +{ + "name": "John Doe", + "address": "123 Main St, Anytown, CA 12345", + "phoneNumbers": [ + { + "type": "home", + "number": "555-555-1234" + }, + { + "type": "work", + "number": "555-555-5678" + } + ] +} + +// 13 +// Input JSON +{ + "employees": [ + { + "id": "001", + "name": "John", + "department": "HR" + }, + { + "id": "002", + "name": "Jane", + "department": "Sales" + }, + { + "id": "003", + "name": "Bob", + "department": "IT" + } + ] +} + +// Jolt Spec +[ + { + "operation": "shift", + "spec": { + "employees": { + "*": { + "@": "employees.@(1,id)" + } + } + } + }, + { + "operation": "remove", + "spec": { + "employees": { + "*": { + "id": "" + } + } + } + } +] + +// Output JSON +{ + "employees" : { + "001" : { + "name" : "John", + "department" : "HR" + }, + "002" : { + "name" : "Jane", + "department" : "Sales" + }, + "003" : { + "name" : "Bob", + "department" : "IT" + } + } +} + +//14 +// Input Json + +{ + "employees": [ + { + "id": "001", + "name": "John", + "department": "HR", + "phone": [ + { + "type": "home", + "number": "555-555-1234" + }, + { + "type": "work", + "number": "555-555-5678" + } + ] + }, + { + "id": "002", + "name": "Jane", + "department": "Sales", + "phone": [ + { + "type": "home", + "number": "555-555-4567" + }, + { + "type": "work", + "number": "555-555-8901" + } + ] + } + ] +} + +// Json Spec + + +[ + { + "operation": "shift", + "spec": { + "employees": { + "*": { + "id": "employees.[#2].&", + "name": "employees.[#2].&", + "phone": { + "*": { + "@number": "employees.[#4].@type" + } + } + } + } + } + }, + { + "operation": "shift", + "spec": { + "employees": { + "*": { + "*": "[#2].&", + "home": "[#2].homePhone", + "work": "[#2].workPhone" + } + } + } + } +] + +// Ouput Json + +[ + { + "id": "001", + "name": "John", + "homePhone": "555-555-1234", + "workPhone": "555-555-5678" + }, + { + "id": "002", + "name": "Jane", + "homePhone": "555-555-4567", + "workPhone": "555-555-8901" + } +] + +// 15 +// Input: +{ + "orders": [ + { + "id": "order1", + "date": "2022-01-01T00:00:00Z", + "customerId": "customer1", + "items": [ + { + "id": "item1", + "name": "Product 1", + "price": 10, + "quantity": 2 + }, + { + "id": "item2", + "name": "Product 2", + "price": 20, + "quantity": 1 + } + ], + "totalPrice": 40 + }, + { + "id": "order2", + "date": "2022-02-01T00:00:00Z", + "customerId": "customer1", + "items": [ + { + "id": "item3", + "name": "Product 3", + "price": 30, + "quantity": 3 + } + ], + "totalPrice": 90 + }, + { + "id": "order3", + "date": "2022-03-01T00:00:00Z", + "customerId": "customer2", + "items": [ + { + "id": "item4", + "name": "Product 4", + "price": 40, + "quantity": 4 + } + ], + "totalPrice": 160 + } + ] +} + + + + +// Transformation: + +[ + { + "operation": "shift", + "spec": { + "orders": { + "*": { + "@": "@(1,customerId).orders[]" + } + } + } + }, + { + "operation": "shift", + "spec": { + "*": "customers" + } + }, + { + "operation": "shift", + "spec": { + "customers": { + "*": { + "orders": { + "*": { + "*": "customers[#4].orders[#2].&", + "totalPrice": "customers[#4].totalAmount" + } + } + } + } + } + }, + { + "operation": "modify-overwrite-beta", + "spec": { + "customers": { + "*": { + "totalAmount": "=intSum(@(1,totalAmount))", + "id": "@(1,orders[0].customerId)" + }, + "[0]": { + "name": "John Doe" + }, + "[1]": { + "name": "Jane Doe" + } + } + } + }, + { + "operation": "remove", + "spec": { + "customers": { + "*": { + "orders": { + "*": { + "customerId": "" + } + } + } + } + } + }, + { + "operation": "sort" + } +] + + + +// Output: + +{ + "customers": [ + { + "id": "customer1", + "name": "John Smith", + "totalAmount": 130, + "orders": [ + { + "id": "order1", + "date": "2022-01-01T00:00:00Z", + "items": [ + { + "id": "item1", + "name": "Product 1", + "price": 10, + "quantity": 2 + }, + { + "id": "item2", + "name": "Product 2", + "price": 20, + "quantity": 1 + } + ], + "totalPrice": 40 + }, + { + "id": "order2", + "date": "2022-02-01T00:00:00Z", + "items": [ + { + "id": "item3", + "name": "Product 3", + "price": 30, + "quantity": 3 + } + ], + "totalPrice": 90 + } + ] + }, + { + "id": "customer2", + "name": "Jane Doe", + "totalAmount": 160, + "orders": [ + { + "id": "order3", + "date": "2022-03-01T00:00:00Z", + "items": [ + { + "id": "item4", + "name": "Product 4", + "price": 40, + "quantity": 4 + } + ], + "totalPrice": 160 + } + ] + } + ] +} +// 16 +// INput Json +{ + "employees": [ + { + "id": "1001", + "name": "John Doe", + "age": 25, + "skills": [ + { + "name": "Java", + "level": "Intermediate" + }, + { + "name": "Python", + "level": "Expert" + } + ] + }, + { + "id": "1002", + "name": "Jane Doe", + "age": 30, + "skills": [ + { + "name": "Java", + "level": "Expert" + } + ] + } + ] +} + +// JSON Spec +{ + "Java": { + "Intermediate": [ + "John Doe" + ], + "Expert": [ + "Jane Doe", + "John Doe" + ] + }, + "Python": { + "Expert": [ + "John Doe" + ] + } +} + +// 17 +// Input JSON + +{ + "products": [ + { + "id": "1001", + "name": "Product 1", + "price": 10.99 + }, + { + "id": "1002", + "name": "Product 2", + "price": 15.99, + "available": true + }, + { + "id": "1003", + "name": "Product 3", + "price": 20.99, + "available": false + } + ] +} + +// Jolt Spec +[ + { + "operation": "modify-default-beta", + "spec": { + "products": { + "*": { + "available": "false" + } + } + } + } +] + +// Output JSON +{ + "products": [ + { + "id": "1001", + "name": "Product 1", + "price": 10.99, + "available": false + }, + { + "id": "1002", + "name": "Product 2", + "price": 15.99, + "available": true + }, + { + "id": "1003", + "name": "Product 3", + "price": 20.99, + "available": false + } + ] +} + +// 18 +// Input JSON +{ + "employees": [ + { + "name": "John", + "age": 30, + "salary": 5000 + }, + { + "name": "Jane", + "age": 35, + "salary": 6000 + }, + { + "name": "Bob", + "age": 40, + "salary": 7000 + } + ] +} + +// Jolt Spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "employees": { + "*": { + "temp": "=divideAndRound(0,@(1,salary),10)", + "salary": "=doubleSum(@(1,salary),@(1,temp))" + } + } + } + }, + { + "operation": "remove", + "spec": { + "temp": "" + } + } +] + +// Output JSON +{ + "employees" : [ { + "name" : "John", + "age" : 30, + "salary" : 5500.0, + "temp" : 500.0 + }, { + "name" : "Jane", + "age" : 35, + "salary" : 6600.0, + "temp" : 600.0 + }, { + "name" : "Bob", + "age" : 40, + "salary" : 7700.0, + "temp" : 700.0 + } ] +} + + + +// 19 +// Input Json + +{ + "products": [ + { + "id": "1001", + "name": "Product 1", + "price": 10.99 + }, + { + "id": "1002", + "name": "Product 2", + "price": 15.99 + }, + { + "id": "1003", + "name": "Product 3", + "price": 20.99 + } + ] +} + +// Json Spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "products": { + "*": { + "price": "=doubleSum(@(1,price),@(1,price))" + } + } + } + }, + { + "operation": "modify-overwrite-beta", + "spec": { + "products": { + "[0]": { + "price": "=divide(@(1,price),2)" + } + } + } + } +] +// Output Json + +{ + "products": [ + { + "id": "1001", + "name": "Product 1", + "price": 21.98 + }, + { + "id": "1002", + "name": "Product 2", + "price": 31.98 + }, + { + "id": "1003", + "name": "Product 3", + "price": 41.98 + } + ] +} +//20 +// Input: + +{ + "employees": [ + { + "name": "John", + "age": 30, + "department": { + "id": 1, + "name": "Sales" + } + }, + { + "name": "Jane", + "age": 35, + "department": { + "id": 2, + "name": "Marketing" + } + }, + { + "name": "Bob", + "age": 40, + "department": { + "id": 1, + "name": "Sales" + } + } + ] +} + +// Transformation: + +[ + { + "operation": "shift", + "spec": { + "employees": { + "*": { + "department": { + "id": "departments[#3].id", + "name": "departments[#3].name" + }, + "name": "departments[#2].employees.name", + "age": "departments[#2].employees.age" + } + } + } + }, + { + "operation": "shift", + "spec": { + "departments": { + "*": { + "@": "departments.@(1,id)[]" + } + } + } + }, + { + "operation": "shift", + "spec": { + "departments": { + "*": { + "*": { + "id": "departments.@(1,id).id", + "name": "departments.@(1,id).name", + "employees": "departments.@(1,id).employees[]" + } + } + } + } + }, + + { + "operation": "modify-overwrite-beta", + "spec": { + "departments": { + "*": { + "*": { + "employees": "&" + }, + "id": "@(1,id[0])", + "name": "@(1,name[0])" + } + } + } + }, + { + "operation": "shift", + "spec": { + "departments": { + "*": "departments" + } + } + } +] + + + +// Output: + + { + "departments" : [ { + "id" : 1, + "name" : "Sales", + "employees" : [ { + "name" : "John", + "age" : 30 + }, { + "name" : "Bob", + "age" : 40 + } ] + }, { + "id" : 2, + "name" : "Marketing", + "employees" : [ { + "name" : "Jane", + "age" : 35 + } ] + } ] +} +// 21 +// Input JSON +{ + "restaurant": { + "rating": { + "value": 3 + }, + "address": { + "value": "India" + } + } +} + +// Jolt Spec +[ + { + "operation": "shift", + "spec": { + "restaurant": { + "rating": { + "value": "Restaurant Rating" + } + } + } + } +] + +// Output JSON +{ + "Restaurant Rating" : 3 +} + + +//22 +// Input JSON +[ + { + "restaurant": { + "rating": { + "value": 9 + }, + "address": { + "value": "India" + } + } + }, + { + "restaurant": { + "rating": { + "value": 7 + }, + "address": { + "value": "United States" + } + } + } +] + +//Jolt Spec +[ + { + "operation": "shift", + "spec": { + "*": { + "restaurant": { + "rating": { + "value": "[#4].Restaurant Rating" + } + } + } + } + } +] + +// Output JSON +[ { + "Restaurant Rating" : 9 +}, { + "Restaurant Rating" : 7 +} ] + +// 23 +// Input JSON +[ + { + "restaurant": { + "rating": { + "value": 9 + }, + "address": { + "value": "India" + } + } + }, + { + "restaurant": { + "rating": { + "value": 7 + }, + "address": { + "value": "United States" + } + } + } +] + +// Jolt spec +[ + { + "operation": "shift", + "spec": { + "*": { + "restaurant": { + "rating": { + "value": "[#4].Restaurant Rating" + }, + "address": { + "value": "[#4].Restaurant Country" + } + } + } + } + } +] + +//Output JSON +[ { + "Restaurant Rating" : 9, + "Restaurant Country" : "India" +}, { + "Restaurant Rating" : 7, + "Restaurant Country" : "United States" +} ] + +//24 +// Input JSON +[ + { + "restaurant": { + "rating": { + "value": 9 + }, + "address": { + "value": "India" + } + }, + "itemsList": [ + { + "itemName": "Example 11", + "itemPrice": 120 + }, + { + "itemName": "Example 12", + "itemPrice": 150 + } + ] + }, + { + "restaurant": { + "rating": { + "value": 7 + }, + "address": { + "value": "United States" + } + }, + "itemsList": [ + { + "itemName": "Example 21", + "itemPrice": 100 + }, + { + "itemName": "Example 22", + "itemPrice": 190 + } + ] + } +] + +// Jolt Spec +[ + { + "operation": "shift", + "spec": { + "*": { + "restaurant": { + "rating": { + "value": "[#4].Restaurant Rating" + }, + "address": { + "value": "[#4].Restaurant Country" + } + }, + "itemsList": { + "*": { + "itemName": "[#4].Dish Name", + "itemPrice": "[#4].Dish Price" + } + } + } + } + } + +] + +// Output Json +[ { + "Restaurant Rating" : 9, + "Restaurant Country" : "India", + "Dish Name" : [ "Example 11", "Example 12" ], + "Dish Price" : [ 120, 150 ] +}, { + "Restaurant Rating" : 7, + "Restaurant Country" : "United States", + "Dish Name" : [ "Example 21", "Example 22" ], + "Dish Price" : [ 100, 190 ] +} ] + +// 25 +// Input JSON +[ + { + "restaurant": { + "rating": { + "value": 9 + }, + "address": { + "value": "India" + } + }, + "itemsList": [ + { + "itemName": "Example 11", + "itemPrice": 120 + }, + { + "itemName": "Example 12", + "itemPrice": 150 + } + ] + }, + { + "restaurant": { + "rating": { + "value": 7 + }, + "address": { + "value": "United States" + } + }, + "itemsList": [ + { + "itemName": "Example 21", + "itemPrice": 100 + }, + { + "itemName": "Example 22", + "itemPrice": 190 + } + ] + } +] + +// Jolt Spec +[ + { + "operation": "shift", + "spec": { + "*": { + "restaurant": { + "rating": { + "value": "[#4].Restaurant Rating" + }, + "address": { + "value": "[#4].Restaurant Country" + } + }, + "itemsList": { + "*": { + "itemName": "[#4].Dishes.[#2].Dish Name", + "itemPrice": "[#4].Dishes.[#2].Dish Price" + } + } + } + } + } + +] + +// Output JSON +[ { + "Restaurant Rating" : 9, + "Restaurant Country" : "India", + "Dishes" : [ { + "Dish Name" : "Example 11", + "Dish Price" : 120 + }, { + "Dish Name" : "Example 12", + "Dish Price" : 150 + } ] +}, { + "Restaurant Rating" : 7, + "Restaurant Country" : "United States", + "Dishes" : [ { + "Dish Name" : "Example 21", + "Dish Price" : 100 + }, { + "Dish Name" : "Example 22", + "Dish Price" : 190 + } ] +} ] + + +// 26 +// Input Json + +[ + { + "returnId": "10051", + "returnQuantity": 2, + "returnPrice": 100, + "returnTax": 12.56 + }, + { + "returnId": "10052", + "returnQuantity": 25, + "returnPrice": 35, + "returnTax": 29.85 + } +] + +// Json Spec + +[ + { + "operation": "modify-default-beta", + "spec": { + "*": { + "Return Id": "@(1,returnId)", + "temp": "=divide(1,@(1,returnQuantity))", + "Return Amount": "=divideAndRound(2,@(1,returnPrice),@(1,temp))", + "Return Total Amount": "=doubleSum(@(1,Return Amount),@(1,returnTax))" + } + } + }, + { + "operation": "remove", + "spec": { + "*": { + "returnId": "", + "returnQuantity": "", + "returnPrice": "", + "returnTax": "", + "temp": "" + } + } + } +] + +// Output Json + +[ + { + "Return Id": "10051", + "Return Amount": 200.0, + "Return Total Amount": 212.56 + }, + { + "Return Id": "10052", + "Return Amount": 875.0, + "Return Total Amount": 904.85 + } +] + + +// 27 +// Input J son +[ + { + "returnId": "10051", + "returnQuantity": 2, + "returnPrice": 100, + "returnTax": 12.56, + "country": "USA" + }, + { + "returnId": "10052", + "returnQuantity": 25, + "returnPrice": 35, + "returnTax": 29.85, + "country": "CA" + }, + { + "returnId": "10053", + "returnQuantity": 5, + "returnPrice": 55, + "returnTax": 9.85, + "country": "" + } +] + +// Json Spec + +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "*": { + "Return Id": "@(1, returnId)", + "temp": "=divide(1,@(1,returnQuantity))", + "Return Amount": "=divide(@(1,returnPrice),@(1,temp))", + "Return Total Amount": "=doubleSum(@(1,Return Amount),@(1,returnTax))" + }, + "[0]": { + "Country": "United States of America" + }, + "[1]": { + "Country": "Canada" + }, + "[2]": { + "Country": "NA" + } + } + }, + { + "operation": "shift", + "spec": { + "*": { + "returnId": "[#2].Return Id", + "Return Amount": "[#2].Return Amount", + "Return Total Amount": "[#2].Return Total Amount", + "Country": "[#2].Country" + } + } + } +] + + // Output Json + + [ + { + "Return Id": "10051", + "Return Amount": 200.0, + "Return Total Amount": 212.56, + "Country": "United States of America" + }, + { + "Return Id": "10052", + "Return Amount": 875.0, + "Return Total Amount": 904.85, + "Country": "Canada" + }, + { + "Return Id": "10053", + "Return Amount": 275.0, + "Return Total Amount": 284.85, + "Country": "NA" + } +] + +// 28 +// Input Json + +[ + { + "returnId": "151", + "returnItemAdjustments": [ + { + "returnItemSeqId": "00001", + "amount": 28.64, + "returnAdjustmentTypeId": "RET_SALES_TAX_ADJ", + "description": "Return Sales Tax", + "createdDate": null, + "returnId": "151", + "returnAdjustmentId": "", + "comments": "Return Sales Tax", + "shipGroupSeqId": null + }, + { + "returnItemSeqId": "00001", + "amount": 58.64, + "returnAdjustmentTypeId": "RET_SALES_TAX_ADJ", + "description": "Return Sales Tax", + "createdDate": null, + "returnId": "151", + "returnAdjustmentId": "", + "comments": "Return Sales Tax", + "shipGroupSeqId": null + } + ] + }, + { + "returnId": "152", + "returnItemAdjustments": [ + { + "returnItemSeqId": "00002", + "amount": 38.64, + "returnAdjustmentTypeId": "RET_SALES_TAX_ADJ", + "description": "Return Sales Tax", + "createdDate": null, + "returnId": "152", + "returnAdjustmentId": "", + "comments": "Return Sales Tax", + "shipGroupSeqId": null + } + ] + } +] + +// Json Spec + +[ + { + "operation": "shift", + "spec": { + "*": { + "returnId": "[#2].returnId", + "returnItemAdjustments": { + "*": { + "amount": "[#4].returnTax" + } + } + } + } + }, + { + "operation": "modify-overwrite-beta", + "spec": { + "*": { + "returnTax": "=doubleSum(@(1,returnTax))" + } + } + } +] + +// Output Json + +[ + { + "returnId": "151", + "returnTax": 87.28 + }, + { + "returnId": "152", + "returnTax": 38.64 + } +] +// 29 +// Input Json + +{ + "person": { + "name": "John Doe", + "age": 30, + "address": { + "city": "New York", + "state": "NY" + } + } +} + +// Json Spec + +[ + { + "operation": "shift", + "spec": { + "person": { + "name": "person_name", + "age": "person_age", + "address": { + "city": "person_address_city", + "state": "person_address_state" + } + } + } + } + ] + +// Output Json + +{ + "person_name": "John Doe", + "person_age": 30, + "person_address_city": "New York", + "person_address_state": "NY" +} + +// 30 +// Input Json + +{ + "person": { + "name": "John Doe", + "age": 30, + "address": { + "city": "New York", + "state": "NY" + } + }, + "employee": { + "name": "Jane Doe", + "salary": 50000, + "office": { + "city": "San Francisco", + "state": "CA" + } + } +} + +// Json Spec + +[ + { + "operation": "shift", + "spec": { + "person": { + "name": "&" + }, + "employee": { + "office": { + "*": "office-&" + } + } + } + } + ] + +// Output Json + +{ + "name": "John Doe", + "office-city": "San Francisco", + "office-state": "CA" +} + + +// 31 +// Input Json +{ + "items": [ + { + "id": "1", + "name": "Book", + "prices": [ + { + "currency": "USD", + "value": 10 + }, + { + "currency": "EUR", + "value": 8 + } + ] + }, + { + "id": "2", + "name": "Pen", + "prices": [ + { + "currency": "USD", + "value": 2 + }, + { + "currency": "EUR", + "value": 1.5 + } + ] + } + ] +} + +// Json Spec +[ + { + "operation": "modify-default-beta", + "spec": { + "items": { + "*": { + "prices": { + "*": { + "temp": "=concat(@(3,id),'_',@(1,currency))" + } + } + } + } + } + }, + { + "operation": "shift", + "spec": { + "items": { + "*": { + "prices": { + "*": { + "@value": "@temp" + } + } + } + } + } + } +] + +// Output Json +{ + "1_USD": 10, + "1_EUR": 8, + "2_USD": 2, + "2_EUR": 1.5 +} +// 32 +// Input JSON +{ + "data": [ + { + "x": "A", + "y": "1", + "value": 10 + }, + { + "x": "A", + "y": "2", + "value": 20 + }, + { + "x": "B", + "y": "1", + "value": 30 + }, + { + "x": "B", + "y": "2", + "value": 40 + } + ] +} + +// JSON spec + +[ + { + "operation": "shift", + "spec": { + "data": { + "*": { + "@value": "@x.@y" + } + } + } + } +] + +// Output JSON +{ + "A" : { + "1" : 10, + "2" : 20 + }, + "B" : { + "1" : 30, + "2" : 40 + } +} +// 33 +// Input Json + +{ + "id": 1, + "name": "John", + "hobbies": [ + { + "name": "reading", + "level": "advanced" + }, + { + "name": "swimming", + "level": "beginner" + } + ] +} + + +// Json Spec + +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "hobbies": { + "*": { + "id": "@(3,id)", + "name": "@(3,name)", + "hobby_level": "@(1,level)", + "hobby_name": "@(1,name)" + } + } + } + }, + { + "operation": "shift", + "spec": { + "hobbies": { + "*": "[#1]" + } + } + }, + { + "operation": "remove", + "spec": { + "*": { + "level": "" + } + } + } +] + +// Output Json + +[ + { + "name": "John", + "id": 1, + "hobby_level": "advanced", + "hobby_name": "John" + }, + { + "name": "John", + "id": 1, + "hobby_level": "beginner", + "hobby_name": "John" + } +] + +// 34 +// Input JSON +{ + "name": "John", + "hobby_1": "reading", + "level_1": "advanced", + "hobby_2": "swimming", + "level_2": "beginner" +} + +// JSON spec +[ + { + "operation": "shift", + "spec": { + "name": "name", + "hobby_*": "hobbies[#2].&(0,1).name", + "level_*": "hobbies[#2].&(0,1).level" + } + } +, + { + "operation": "shift", + "spec": { + "name": "name", + "hobbies": { + "*": { + "*": { + "name": "hobbies[#2].name", + "level": "hobbies[#2].level" + } + } + } + } + } +] + +// output json +{ + "name": "John", + "hobbies": [ + { + "name": "reading", + "level": "advanced" + }, + { + "name": "swimming", + "level": "beginner" + } + ] +} \ No newline at end of file From c915158eaebb1dd74ab628773a0140462dc0d4f6 Mon Sep 17 00:00:00 2001 From: Prakhar Yadav Date: Wed, 24 May 2023 10:43:59 +0530 Subject: [PATCH 2/5] Added the Jolt transformation for problem statement 16 --- Jolt Transformation.json | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Jolt Transformation.json b/Jolt Transformation.json index a374b20b..472c3dd4 100644 --- a/Jolt Transformation.json +++ b/Jolt Transformation.json @@ -600,7 +600,7 @@ } //10 -// Input JSON +// Input JSON { "name": "John Smith", "age": 35, @@ -1161,6 +1161,25 @@ } // JSON Spec + +[ + { + "operation": "shift", + "spec": { + "employees": { + "*": { + "skills": { + "*": { + "@(2,name)": "@(1,name).@(1,level)[]" + } + } + } + } + } + } +] + +// Output { "Java": { "Intermediate": [ From 0be0ec93250d4f5d4d2b450062b702447ccf68bc Mon Sep 17 00:00:00 2001 From: Prakhar Yadav Date: Thu, 25 May 2023 12:19:45 +0530 Subject: [PATCH 3/5] Made some changes in the Jolt Spec of problem statement 32 and 34 --- Jolt Transformation.json | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/Jolt Transformation.json b/Jolt Transformation.json index 472c3dd4..d75d3c08 100644 --- a/Jolt Transformation.json +++ b/Jolt Transformation.json @@ -2261,13 +2261,12 @@ "spec": { "data": { "*": { - "@value": "@x.@y" + "value": "@(1,x).@(1,y)" } } } - } + } ] - // Output JSON { "A" : { @@ -2361,27 +2360,15 @@ // JSON spec [ + { "operation": "shift", "spec": { - "name": "name", - "hobby_*": "hobbies[#2].&(0,1).name", - "level_*": "hobbies[#2].&(0,1).level" - } - } -, - { - "operation": "shift", - "spec": { - "name": "name", - "hobbies": { - "*": { - "*": { - "name": "hobbies[#2].name", - "level": "hobbies[#2].level" - } - } - } + "name": "&", + "hobby_1": "hobbies[0].name", + "level_1": "hobbies[0].level", + "hobby_2": "hobbies[1].name", + "level_2": "hobbies[1].level" } } ] From 1a09f35efdbb390aaae15a3d626dc463401c6a2c Mon Sep 17 00:00:00 2001 From: Prakhar Yadav Date: Wed, 31 May 2023 16:10:01 +0530 Subject: [PATCH 4/5] Added the approaches of all the jolt transformations, made some changes majorly to improve the readability of the readability of the transformation specs --- Jolt Transformation.json | 2389 ------------------------------ Module 5/Problem_1/Q1.json | 182 +++ Module 5/Problem_1/approach.md | 8 + Module 5/Problem_10/Q10.json | 70 + Module 5/Problem_10/approach.md | 7 + Module 5/Problem_11/Q11.json | 41 + Module 5/Problem_11/approach.md | 5 + Module 5/Problem_12/Q_12.json | 63 + Module 5/Problem_12/approach.md | 7 + Module 5/Problem_13/Q13.json | 53 + Module 5/Problem_13/approach.md | 5 + Module 5/Problem_14/Q14.json | 83 ++ Module 5/Problem_14/approach.md | 6 + Module 5/Problem_15/Q15.json | 190 +++ Module 5/Problem_15/approach.md | 11 + Module 5/Problem_16/Q16.json | 69 + Module 5/Problem_16/approach.md | 5 + Module 5/Problem_17/Q17.json | 61 + Module 5/Problem_17/approach.md | 5 + Module 5/Problem_18/Q18.json | 61 + Module 5/Problem_18/approach.md | 7 + Module 5/Problem_19/Q_19.json | 63 + Module 5/Problem_19/approach.md | 7 + Module 5/Problem_2/Q2.json | 25 + Module 5/Problem_2/approach.md | 5 + Module 5/Problem_20/Q20.json | 112 ++ Module 5/Problem_20/approach.md | 8 + Module 5/Problem_21/Q21.json | 30 + Module 5/Problem_21/approach.md | 6 + Module 5/Problem_22/Q22.json | 46 + Module 5/Problem_22/approach.md | 5 + Module 5/Problem_23/Q23.json | 51 + Module 5/Problem_23/approach.md | 5 + Module 5/Problem_24/Q24.json | 82 + Module 5/Problem_24/approach.md | 5 + Module 5/Problem_25/Q25.json | 92 ++ Module 5/Problem_25/approach.md | 5 + Module 5/Problem_26/Q26.json | 56 + Module 5/Problem_26/approach.md | 7 + Module 5/Problem_27/Q27.json | 81 + Module 5/Problem_27/approach.md | 7 + Module 5/Problem_28/Q28.json | 83 ++ Module 5/Problem_28/approach.md | 8 + Module 5/Problem_29/Q29.json | 35 + Module 5/Problem_29/approach.md | 5 + Module 5/Problem_3/Q3.json | 30 + Module 5/Problem_3/approach.md | 6 + Module 5/Problem_30/Q30.json | 43 + Module 5/Problem_30/approach.md | 5 + Module 5/Problem_31/Q31.json | 73 + Module 5/Problem_31/approach.md | 8 + Module 5/Problem_32/Q32.json | 51 + Module 5/Problem_32/approach.md | 5 + Module 5/Problem_33/Q33.json | 61 + Module 5/Problem_33/approach.md | 7 + Module 5/Problem_34/Q34.json | 38 + Module 5/Problem_34/approach.md | 5 + Module 5/Problem_4/Q4.json | 38 + Module 5/Problem_4/approach.md | 5 + Module 5/Problem_5/Q5.json | 42 + Module 5/Problem_5/approach.md | 6 + Module 5/Problem_6/Q6.json | 88 ++ Module 5/Problem_6/approach.md | 7 + Module 5/Problem_7/Q7.json | 55 + Module 5/Problem_7/approach.json | 7 + Module 5/Problem_8/Q8.json | 74 + Module 5/Problem_8/approach.md | 8 + Module 5/Problem_9/Q9.json | 34 + Module 5/Problem_9/approach.md | 5 + 69 files changed, 2469 insertions(+), 2389 deletions(-) delete mode 100644 Jolt Transformation.json create mode 100644 Module 5/Problem_1/Q1.json create mode 100644 Module 5/Problem_1/approach.md create mode 100644 Module 5/Problem_10/Q10.json create mode 100644 Module 5/Problem_10/approach.md create mode 100644 Module 5/Problem_11/Q11.json create mode 100644 Module 5/Problem_11/approach.md create mode 100644 Module 5/Problem_12/Q_12.json create mode 100644 Module 5/Problem_12/approach.md create mode 100644 Module 5/Problem_13/Q13.json create mode 100644 Module 5/Problem_13/approach.md create mode 100644 Module 5/Problem_14/Q14.json create mode 100644 Module 5/Problem_14/approach.md create mode 100644 Module 5/Problem_15/Q15.json create mode 100644 Module 5/Problem_15/approach.md create mode 100644 Module 5/Problem_16/Q16.json create mode 100644 Module 5/Problem_16/approach.md create mode 100644 Module 5/Problem_17/Q17.json create mode 100644 Module 5/Problem_17/approach.md create mode 100644 Module 5/Problem_18/Q18.json create mode 100644 Module 5/Problem_18/approach.md create mode 100644 Module 5/Problem_19/Q_19.json create mode 100644 Module 5/Problem_19/approach.md create mode 100644 Module 5/Problem_2/Q2.json create mode 100644 Module 5/Problem_2/approach.md create mode 100644 Module 5/Problem_20/Q20.json create mode 100644 Module 5/Problem_20/approach.md create mode 100644 Module 5/Problem_21/Q21.json create mode 100644 Module 5/Problem_21/approach.md create mode 100644 Module 5/Problem_22/Q22.json create mode 100644 Module 5/Problem_22/approach.md create mode 100644 Module 5/Problem_23/Q23.json create mode 100644 Module 5/Problem_23/approach.md create mode 100644 Module 5/Problem_24/Q24.json create mode 100644 Module 5/Problem_24/approach.md create mode 100644 Module 5/Problem_25/Q25.json create mode 100644 Module 5/Problem_25/approach.md create mode 100644 Module 5/Problem_26/Q26.json create mode 100644 Module 5/Problem_26/approach.md create mode 100644 Module 5/Problem_27/Q27.json create mode 100644 Module 5/Problem_27/approach.md create mode 100644 Module 5/Problem_28/Q28.json create mode 100644 Module 5/Problem_28/approach.md create mode 100644 Module 5/Problem_29/Q29.json create mode 100644 Module 5/Problem_29/approach.md create mode 100644 Module 5/Problem_3/Q3.json create mode 100644 Module 5/Problem_3/approach.md create mode 100644 Module 5/Problem_30/Q30.json create mode 100644 Module 5/Problem_30/approach.md create mode 100644 Module 5/Problem_31/Q31.json create mode 100644 Module 5/Problem_31/approach.md create mode 100644 Module 5/Problem_32/Q32.json create mode 100644 Module 5/Problem_32/approach.md create mode 100644 Module 5/Problem_33/Q33.json create mode 100644 Module 5/Problem_33/approach.md create mode 100644 Module 5/Problem_34/Q34.json create mode 100644 Module 5/Problem_34/approach.md create mode 100644 Module 5/Problem_4/Q4.json create mode 100644 Module 5/Problem_4/approach.md create mode 100644 Module 5/Problem_5/Q5.json create mode 100644 Module 5/Problem_5/approach.md create mode 100644 Module 5/Problem_6/Q6.json create mode 100644 Module 5/Problem_6/approach.md create mode 100644 Module 5/Problem_7/Q7.json create mode 100644 Module 5/Problem_7/approach.json create mode 100644 Module 5/Problem_8/Q8.json create mode 100644 Module 5/Problem_8/approach.md create mode 100644 Module 5/Problem_9/Q9.json create mode 100644 Module 5/Problem_9/approach.md diff --git a/Jolt Transformation.json b/Jolt Transformation.json deleted file mode 100644 index d75d3c08..00000000 --- a/Jolt Transformation.json +++ /dev/null @@ -1,2389 +0,0 @@ -// 1 -// Input JSON -{ - "orders": [ - { - "orderId": 1, - "orderDate": "2022-02-20T12:34:56Z", - "customer": { - "customerId": 1, - "firstName": "John", - "lastName": "Doe", - "email": "johndoe@example.com", - "address": { - "street": "123 Main St", - "city": "Anytown", - "state": "CA", - "zip": "12345" - } - }, - "items": [ - { - "itemId": 1, - "name": "Product A", - "quantity": 2, - "price": 10.0 - }, - { - "itemId": 2, - "name": "Product B", - "quantity": 1, - "price": 20.0 - } - ] - }, - { - "orderId": 2, - "orderDate": "2022-02-21T09:12:34Z", - "customer": { - "customerId": 2, - "firstName": "Jane", - "lastName": "Smith", - "email": "janesmith@example.com", - "address": { - "street": "456 Oak St", - "city": "Somewhere", - "state": "NY", - "zip": "67890" - } - }, - "items": [ - { - "itemId": 3, - "name": "Product C", - "quantity": 3, - "price": 15.0 - } - ] - } - ] -} -//JSON Spec -[ - { - "operation": "modify-overwrite-beta", - "spec": { - "orders": { - "*": { - "customer": { - "address": "=concat(@(1,address.street),' ',@(1,address.city), ' ', @(1,address.state), ' ',@(1,address.zip))" - }, - "itemTemp": "@(1,items)" - } - } - } - }, - - { - "operation": "modify-overwrite-beta", - "spec": { - "orders": { - "*": { - "itemTemp": { - "*": { - "inverseValue": "=divide(1,@(1,price))", - "temp": "=divideAndRound(2, @(1,quantity), @(1,inverseValue))" - } - } - } - } - } - }, - { - "operation": "shift", - "spec": { - "orders": { - "*": { - "*": "orders[&1].&", - "itemTemp": { - "*": { - "temp": "orders[#4].total" - } - } - } - } - } - }, - { - "operation": "modify-overwrite-beta", - "spec": { - "orders": { - "*": { - "total": "=doubleSum(@(1,total))" - } - } - } - }, - - { - "operation": "remove", - "spec": { - "orders": { - "*": { - "items": { - "*": { - "inverseValue": "", - "temp": "" - } - } - } - } - } - } -] -//Output JSON -{ - "orders": [ - { - "orderId": 1, - "orderDate": "2022-02-20T12:34:56Z", - "customer": { - "customerId": 1, - "fullName": "John Doe", - "email": "johndoe@example.com", - "address": "123 Main St, Anytown, CA 12345" - }, - "items": [ - { - "itemId": 1, - "name": "Product A", - "quantity": 2, - "price": 10.0 - }, - { - "itemId": 2, - "name": "Product B", - "quantity": 1, - "price": 20.0 - } - ], - "total": 40.0 - }, - { - "orderId": 2, - "orderDate": "2022-02-21T09:12:34Z", - "customer": { - "customerId": 2, - "fullName": "Jane Smith", - "email": "janesmith@example.com", - "address": "456 Oak St, Somewhere, NY 67890" - }, - "items": [ - { - "itemId": 3, - "name": "Product C", - "quantity": 3, - "price": 15.0 - } - ], - "total": 45.0 - } - ] -} - -// 2. -// Input JSON -{ - "name": "John", - "age": 35, - "city": "New York" -} - -// Transformation Jolt -[ - { - "operation": "shift", - "spec": { - "name": "Name", - "age": "Age", - "city": "City" - } - } -] - -// Output JSON -{ - "Name": "John", - "Age": 35, - "City": "New York" -} - - -// 3. -// Input JSON -{ - "name": "John", - "age": 35, - "city": "New York", - "phone": "+1-555-123-4567" -} - -// Transformation Jolt -[ - { - "operation": "shift", - "spec": { - "name": "Name", - "age": "Age", - "city": "City", - "phone": "Phone" - } - } -] - -// Output JSON -{ - "Name": "John", - "Age": 35, - "Contact": { - "City": "New York", - "Phone": "+1-555-123-4567" - } -} -//4 -//Input JSON - -{ - "name": "John", - "age": 35, - "hobbies": [ - "reading", - "movies", - "travel" - ] -} - -//Jolt Spec -[ - { - "operation": "shift", - "spec": { - "name": "Name", - "age": "Age", - "hobbies": { - "*": "Hobbies[&].Name" - } - } - } -] - -//Output JSON -{ - "Name" : "John", - "Age" : 35, - "Hobbies" : [ { - "Name" : "reading" - }, { - "Name" : "movies" - }, { - "Name" : "travel" - } ] -} - -//5 -//Input JSON - -{ - "firstName": "John", - "lastName": "Doe", - "email": "johndoe@example.com", - "address": { - "street": "123 Main St", - "city": "Anytown", - "state": "CA", - "zip": "12345" - } -} - -// Jolt spec -[ - { - "operation": "modify-overwrite-beta", - "spec": { - "fullName": "=concat(@(1,firstName),' ',@(1,lastName))" - } - } - , { - "operation": "shift", - "spec": { - "fullName": "&", - "email": "&", - "address": { - "city": "&", - "zip": "&" - } - } - } -] - -// Output JSON -{ - "fullName" : "John Doe", - "email" : "johndoe@example.com", - "city" : "Anytown", - "zip" : "12345" -} - -//6 -// Input JSON -{ - "users": [ - { - "name": "John Doe", - "age": 35, - "address": { - "street": "123 Main St", - "city": "Anytown", - "state": "CA", - "zip": "12345" - }, - "hobbies": [ - { - "name": "reading", - "type": "indoor" - }, - { - "name": "hiking", - "type": "outdoor" - } - ] - }, - { - "name": "Jane Doe", - "age": 30, - "address": { - "street": "456 First St", - "city": "Othertown", - "state": "NY", - "zip": "67890" - }, - "hobbies": [ - { - "name": "swimming", - "type": "outdoor" - }, - { - "name": "painting", - "type": "indoor" - } - ] - } - ] -} - -// Jolt Spec -[ - { - "operation": "modify-overwrite-beta", - "spec": { - "users": { - "*": { - "Address": "=concat(@(1,address.street),', ',@(1,address.city),', ',@(1,address.state),', ',@(1,address.zip))" - } - } - } - }, - { - "operation": "shift", - "spec": { - "users": { - "*": { - "name": "[#2].Name", - "Address": "[#2].Address", - "hobbies": { - "*": { - "name": "[#4].Hobbies" - } - } - } - } - } - } -] - -//Output JSON -[ { - "Name" : "John Doe", - "Address" : "123 Main St, Anytown, CA, 12345", - "Hobbies" : [ "reading", "hiking" ] -}, { - "Name" : "Jane Doe", - "Address" : "456 First St, Othertown, NY, 67890", - "Hobbies" : [ "swimming", "painting" ] -} ] - - -//7 -//Input JSON -{ - "students": [ - { - "name": "John Doe", - "age": 23, - "email": "john.doe@example.com" - }, - { - "name": "Jane Smith", - "age": 25, - "email": "jane.smith@example.com" - } - ] -} - -//Jolt Spec -[ - { - "operation": "shift", - "spec": { - "students": { - "*": "[#1]" - } - } - } - , - { - "operation": "modify-overwrite-beta", - "spec": { - "*": { - "Name": "name", - "Age": "age", - "domainTemp": "=split('@',@(1,email))", - "Domain": "=lastElement(@(1,domainTemp))" - } - } - }, - { - "operation": "remove", - "spec": { - "*": { - "name": "", - "age": "", - "email": "", - "domainTemp": "" - } - } - } -] - -//Output JSON -[ { - "Name" : "name", - "Age" : "age", - "Domain" : "example.com" -}, { - "Name" : "name", - "Age" : "age", - "Domain" : "example.com" -} -] - -// 8 -// Input: -{ - "employees": [ - { - "name": "John Doe", - "salary": 50000, - "department": "Sales" - }, - { - "name": "Jane Smith", - "salary": 60000 - }, - { - "name": "Bob Johnson", - "department": "IT" - } - ] -} - - -// Transformation: - -[ - { - "operation": "modify-default-beta", - "spec": { - "employees": { - "[0]": { - "bonus": 1000, - "tempBonus": 1000 - }, - "[1]": { - "bonus": 1500, - "tempBonus": 1500 - }, - "[2]": { - "salary":4500, - "bonus": 900, - "tempBonus": 900 - } - } - } - }, - { - "operation": "shift", - "spec": { - "employees": { - "*": { - "*": "employees[&1].&", - "tempBonus": "totalBonus[]" - } - } - } - }, - { - "operation": "modify-overwrite-beta", - "spec": { - "totalBonus": "=intSum(@(1,totalBonus))" - } - } - - - - - -] - - -// Output: - -{ - "employees" : [ { - "name" : [ "John Doe", "Jane Smith", "Bob Johnson" ] - }, { - "salary" : [ 50000, 60000 ], - "department" : "IT" - }, { - "department" : "Sales", - "bonus" : [ 1500, 900 ] - }, { - "bonus" : 1000 - } ], - "totalBonus" : 3400 -} - -//9 -// Input JSON -{ - "name": "John", - "age": 30, - "address": { - "street": "123 Main St", - "city": "Anytown", - "state": "CA", - "zip": "12345" - } -} - -//Jolt Spec -[ - { - "operation": "remove", - "spec": { - "address": { - "state": "" - } - } - } -] - -// Output JSON -{ - "name" : "John", - "age" : 30, - "address" : { - "street" : "123 Main St", - "city" : "Anytown", - "zip" : "12345" - } -} - -//10 -// Input JSON -{ - "name": "John Smith", - "age": 35, - "address": { - "street": "123 Main St", - "city": "Anytown", - "state": "CA", - "zip": "12345" - }, - "phone_numbers": [ - { - "type": "home", - "number": "555-1234" - }, - { - "type": "work", - "number": "555-5678" - } - ] -} - -// Jolt Spec -[ - { - "operation": "modify-overwrite-beta", - "spec": { - "fullName": "=split(' ',@(2,name))", - "first_name": "=firstElement(@(1,fullName))", - "last_name": "=lastElement(@(1,fullName))", - "phone_number_count": "=size(@(1,phone_numbers))" - } - }, - { - "operation": "shift", - "spec": { - "first_name": "&", - "last_name": "&", - "age": "&", - "address": "&", - "phone_numbers": "&", - "phone_number_count": "&" - } - } - -] - -//Output JSON -{ - "first_name": "John", - "last_name": "Smith", - "age": 35, - "address": { - "street": "123 Main St", - "city": "Anytown", - "state": "CA", - "zip": "12345" - }, - "phone_numbers": [ - { - "type": "home", - "number": "555-1234" - }, - { - "type": "work", - "number": "555-5678" - } - ], - "phone_number_count": 2 -} - -// 11 -// Input JSON -{ - "items": [ - { - "name": "item1", - "value": 10 - }, - { - "name": "item2", - "value": 20 - } - ] -} - -// Jolt Spec -[ - - { - "operation": "shift", - "spec": { - "items": { - "*": { - "name": "items[#2].itemName", - "value": "items[#2].itemValue" - } - } - } - } - -] - -// Output JSON -{ - "items" : [ { - "itemName" : "item1", - "itemValue" : 10 - }, { - "itemName" : "item2", - "itemValue" : 20 - } ] -} - -// 12 -// Input JSON -{ - "employee": { - "firstName": "John", - "lastName": "Doe", - "address": { - "street": "123 Main St", - "city": "Anytown", - "state": "CA", - "zip": "12345" - }, - "phones": [ - { - "type": "home", - "number": "555-555-1234" - }, - { - "type": "work", - "number": "555-555-5678" - } - ] - } -} - -// Jolt Spec -[ - - { - "operation": "modify-overwrite-beta", - "spec": { - "employee": { - "name": "=concat(@(1,firstName),' ', @(1,lastName))", - "address": "=concat(@(1,address.street),' ', @(1,address.city),' ', @(1,address.state),' ', @(1,address.zip))" - } - } - }, - { - "operation": "shift", - "spec": { - "employee": { - "name": "name", - "address": "&", - "phones": "phoneNumbers" - } - } - } -] - -// Output JSON -{ - "name": "John Doe", - "address": "123 Main St, Anytown, CA 12345", - "phoneNumbers": [ - { - "type": "home", - "number": "555-555-1234" - }, - { - "type": "work", - "number": "555-555-5678" - } - ] -} - -// 13 -// Input JSON -{ - "employees": [ - { - "id": "001", - "name": "John", - "department": "HR" - }, - { - "id": "002", - "name": "Jane", - "department": "Sales" - }, - { - "id": "003", - "name": "Bob", - "department": "IT" - } - ] -} - -// Jolt Spec -[ - { - "operation": "shift", - "spec": { - "employees": { - "*": { - "@": "employees.@(1,id)" - } - } - } - }, - { - "operation": "remove", - "spec": { - "employees": { - "*": { - "id": "" - } - } - } - } -] - -// Output JSON -{ - "employees" : { - "001" : { - "name" : "John", - "department" : "HR" - }, - "002" : { - "name" : "Jane", - "department" : "Sales" - }, - "003" : { - "name" : "Bob", - "department" : "IT" - } - } -} - -//14 -// Input Json - -{ - "employees": [ - { - "id": "001", - "name": "John", - "department": "HR", - "phone": [ - { - "type": "home", - "number": "555-555-1234" - }, - { - "type": "work", - "number": "555-555-5678" - } - ] - }, - { - "id": "002", - "name": "Jane", - "department": "Sales", - "phone": [ - { - "type": "home", - "number": "555-555-4567" - }, - { - "type": "work", - "number": "555-555-8901" - } - ] - } - ] -} - -// Json Spec - - -[ - { - "operation": "shift", - "spec": { - "employees": { - "*": { - "id": "employees.[#2].&", - "name": "employees.[#2].&", - "phone": { - "*": { - "@number": "employees.[#4].@type" - } - } - } - } - } - }, - { - "operation": "shift", - "spec": { - "employees": { - "*": { - "*": "[#2].&", - "home": "[#2].homePhone", - "work": "[#2].workPhone" - } - } - } - } -] - -// Ouput Json - -[ - { - "id": "001", - "name": "John", - "homePhone": "555-555-1234", - "workPhone": "555-555-5678" - }, - { - "id": "002", - "name": "Jane", - "homePhone": "555-555-4567", - "workPhone": "555-555-8901" - } -] - -// 15 -// Input: -{ - "orders": [ - { - "id": "order1", - "date": "2022-01-01T00:00:00Z", - "customerId": "customer1", - "items": [ - { - "id": "item1", - "name": "Product 1", - "price": 10, - "quantity": 2 - }, - { - "id": "item2", - "name": "Product 2", - "price": 20, - "quantity": 1 - } - ], - "totalPrice": 40 - }, - { - "id": "order2", - "date": "2022-02-01T00:00:00Z", - "customerId": "customer1", - "items": [ - { - "id": "item3", - "name": "Product 3", - "price": 30, - "quantity": 3 - } - ], - "totalPrice": 90 - }, - { - "id": "order3", - "date": "2022-03-01T00:00:00Z", - "customerId": "customer2", - "items": [ - { - "id": "item4", - "name": "Product 4", - "price": 40, - "quantity": 4 - } - ], - "totalPrice": 160 - } - ] -} - - - - -// Transformation: - -[ - { - "operation": "shift", - "spec": { - "orders": { - "*": { - "@": "@(1,customerId).orders[]" - } - } - } - }, - { - "operation": "shift", - "spec": { - "*": "customers" - } - }, - { - "operation": "shift", - "spec": { - "customers": { - "*": { - "orders": { - "*": { - "*": "customers[#4].orders[#2].&", - "totalPrice": "customers[#4].totalAmount" - } - } - } - } - } - }, - { - "operation": "modify-overwrite-beta", - "spec": { - "customers": { - "*": { - "totalAmount": "=intSum(@(1,totalAmount))", - "id": "@(1,orders[0].customerId)" - }, - "[0]": { - "name": "John Doe" - }, - "[1]": { - "name": "Jane Doe" - } - } - } - }, - { - "operation": "remove", - "spec": { - "customers": { - "*": { - "orders": { - "*": { - "customerId": "" - } - } - } - } - } - }, - { - "operation": "sort" - } -] - - - -// Output: - -{ - "customers": [ - { - "id": "customer1", - "name": "John Smith", - "totalAmount": 130, - "orders": [ - { - "id": "order1", - "date": "2022-01-01T00:00:00Z", - "items": [ - { - "id": "item1", - "name": "Product 1", - "price": 10, - "quantity": 2 - }, - { - "id": "item2", - "name": "Product 2", - "price": 20, - "quantity": 1 - } - ], - "totalPrice": 40 - }, - { - "id": "order2", - "date": "2022-02-01T00:00:00Z", - "items": [ - { - "id": "item3", - "name": "Product 3", - "price": 30, - "quantity": 3 - } - ], - "totalPrice": 90 - } - ] - }, - { - "id": "customer2", - "name": "Jane Doe", - "totalAmount": 160, - "orders": [ - { - "id": "order3", - "date": "2022-03-01T00:00:00Z", - "items": [ - { - "id": "item4", - "name": "Product 4", - "price": 40, - "quantity": 4 - } - ], - "totalPrice": 160 - } - ] - } - ] -} -// 16 -// INput Json -{ - "employees": [ - { - "id": "1001", - "name": "John Doe", - "age": 25, - "skills": [ - { - "name": "Java", - "level": "Intermediate" - }, - { - "name": "Python", - "level": "Expert" - } - ] - }, - { - "id": "1002", - "name": "Jane Doe", - "age": 30, - "skills": [ - { - "name": "Java", - "level": "Expert" - } - ] - } - ] -} - -// JSON Spec - -[ - { - "operation": "shift", - "spec": { - "employees": { - "*": { - "skills": { - "*": { - "@(2,name)": "@(1,name).@(1,level)[]" - } - } - } - } - } - } -] - -// Output -{ - "Java": { - "Intermediate": [ - "John Doe" - ], - "Expert": [ - "Jane Doe", - "John Doe" - ] - }, - "Python": { - "Expert": [ - "John Doe" - ] - } -} - -// 17 -// Input JSON - -{ - "products": [ - { - "id": "1001", - "name": "Product 1", - "price": 10.99 - }, - { - "id": "1002", - "name": "Product 2", - "price": 15.99, - "available": true - }, - { - "id": "1003", - "name": "Product 3", - "price": 20.99, - "available": false - } - ] -} - -// Jolt Spec -[ - { - "operation": "modify-default-beta", - "spec": { - "products": { - "*": { - "available": "false" - } - } - } - } -] - -// Output JSON -{ - "products": [ - { - "id": "1001", - "name": "Product 1", - "price": 10.99, - "available": false - }, - { - "id": "1002", - "name": "Product 2", - "price": 15.99, - "available": true - }, - { - "id": "1003", - "name": "Product 3", - "price": 20.99, - "available": false - } - ] -} - -// 18 -// Input JSON -{ - "employees": [ - { - "name": "John", - "age": 30, - "salary": 5000 - }, - { - "name": "Jane", - "age": 35, - "salary": 6000 - }, - { - "name": "Bob", - "age": 40, - "salary": 7000 - } - ] -} - -// Jolt Spec -[ - { - "operation": "modify-overwrite-beta", - "spec": { - "employees": { - "*": { - "temp": "=divideAndRound(0,@(1,salary),10)", - "salary": "=doubleSum(@(1,salary),@(1,temp))" - } - } - } - }, - { - "operation": "remove", - "spec": { - "temp": "" - } - } -] - -// Output JSON -{ - "employees" : [ { - "name" : "John", - "age" : 30, - "salary" : 5500.0, - "temp" : 500.0 - }, { - "name" : "Jane", - "age" : 35, - "salary" : 6600.0, - "temp" : 600.0 - }, { - "name" : "Bob", - "age" : 40, - "salary" : 7700.0, - "temp" : 700.0 - } ] -} - - - -// 19 -// Input Json - -{ - "products": [ - { - "id": "1001", - "name": "Product 1", - "price": 10.99 - }, - { - "id": "1002", - "name": "Product 2", - "price": 15.99 - }, - { - "id": "1003", - "name": "Product 3", - "price": 20.99 - } - ] -} - -// Json Spec -[ - { - "operation": "modify-overwrite-beta", - "spec": { - "products": { - "*": { - "price": "=doubleSum(@(1,price),@(1,price))" - } - } - } - }, - { - "operation": "modify-overwrite-beta", - "spec": { - "products": { - "[0]": { - "price": "=divide(@(1,price),2)" - } - } - } - } -] -// Output Json - -{ - "products": [ - { - "id": "1001", - "name": "Product 1", - "price": 21.98 - }, - { - "id": "1002", - "name": "Product 2", - "price": 31.98 - }, - { - "id": "1003", - "name": "Product 3", - "price": 41.98 - } - ] -} -//20 -// Input: - -{ - "employees": [ - { - "name": "John", - "age": 30, - "department": { - "id": 1, - "name": "Sales" - } - }, - { - "name": "Jane", - "age": 35, - "department": { - "id": 2, - "name": "Marketing" - } - }, - { - "name": "Bob", - "age": 40, - "department": { - "id": 1, - "name": "Sales" - } - } - ] -} - -// Transformation: - -[ - { - "operation": "shift", - "spec": { - "employees": { - "*": { - "department": { - "id": "departments[#3].id", - "name": "departments[#3].name" - }, - "name": "departments[#2].employees.name", - "age": "departments[#2].employees.age" - } - } - } - }, - { - "operation": "shift", - "spec": { - "departments": { - "*": { - "@": "departments.@(1,id)[]" - } - } - } - }, - { - "operation": "shift", - "spec": { - "departments": { - "*": { - "*": { - "id": "departments.@(1,id).id", - "name": "departments.@(1,id).name", - "employees": "departments.@(1,id).employees[]" - } - } - } - } - }, - - { - "operation": "modify-overwrite-beta", - "spec": { - "departments": { - "*": { - "*": { - "employees": "&" - }, - "id": "@(1,id[0])", - "name": "@(1,name[0])" - } - } - } - }, - { - "operation": "shift", - "spec": { - "departments": { - "*": "departments" - } - } - } -] - - - -// Output: - - { - "departments" : [ { - "id" : 1, - "name" : "Sales", - "employees" : [ { - "name" : "John", - "age" : 30 - }, { - "name" : "Bob", - "age" : 40 - } ] - }, { - "id" : 2, - "name" : "Marketing", - "employees" : [ { - "name" : "Jane", - "age" : 35 - } ] - } ] -} -// 21 -// Input JSON -{ - "restaurant": { - "rating": { - "value": 3 - }, - "address": { - "value": "India" - } - } -} - -// Jolt Spec -[ - { - "operation": "shift", - "spec": { - "restaurant": { - "rating": { - "value": "Restaurant Rating" - } - } - } - } -] - -// Output JSON -{ - "Restaurant Rating" : 3 -} - - -//22 -// Input JSON -[ - { - "restaurant": { - "rating": { - "value": 9 - }, - "address": { - "value": "India" - } - } - }, - { - "restaurant": { - "rating": { - "value": 7 - }, - "address": { - "value": "United States" - } - } - } -] - -//Jolt Spec -[ - { - "operation": "shift", - "spec": { - "*": { - "restaurant": { - "rating": { - "value": "[#4].Restaurant Rating" - } - } - } - } - } -] - -// Output JSON -[ { - "Restaurant Rating" : 9 -}, { - "Restaurant Rating" : 7 -} ] - -// 23 -// Input JSON -[ - { - "restaurant": { - "rating": { - "value": 9 - }, - "address": { - "value": "India" - } - } - }, - { - "restaurant": { - "rating": { - "value": 7 - }, - "address": { - "value": "United States" - } - } - } -] - -// Jolt spec -[ - { - "operation": "shift", - "spec": { - "*": { - "restaurant": { - "rating": { - "value": "[#4].Restaurant Rating" - }, - "address": { - "value": "[#4].Restaurant Country" - } - } - } - } - } -] - -//Output JSON -[ { - "Restaurant Rating" : 9, - "Restaurant Country" : "India" -}, { - "Restaurant Rating" : 7, - "Restaurant Country" : "United States" -} ] - -//24 -// Input JSON -[ - { - "restaurant": { - "rating": { - "value": 9 - }, - "address": { - "value": "India" - } - }, - "itemsList": [ - { - "itemName": "Example 11", - "itemPrice": 120 - }, - { - "itemName": "Example 12", - "itemPrice": 150 - } - ] - }, - { - "restaurant": { - "rating": { - "value": 7 - }, - "address": { - "value": "United States" - } - }, - "itemsList": [ - { - "itemName": "Example 21", - "itemPrice": 100 - }, - { - "itemName": "Example 22", - "itemPrice": 190 - } - ] - } -] - -// Jolt Spec -[ - { - "operation": "shift", - "spec": { - "*": { - "restaurant": { - "rating": { - "value": "[#4].Restaurant Rating" - }, - "address": { - "value": "[#4].Restaurant Country" - } - }, - "itemsList": { - "*": { - "itemName": "[#4].Dish Name", - "itemPrice": "[#4].Dish Price" - } - } - } - } - } - -] - -// Output Json -[ { - "Restaurant Rating" : 9, - "Restaurant Country" : "India", - "Dish Name" : [ "Example 11", "Example 12" ], - "Dish Price" : [ 120, 150 ] -}, { - "Restaurant Rating" : 7, - "Restaurant Country" : "United States", - "Dish Name" : [ "Example 21", "Example 22" ], - "Dish Price" : [ 100, 190 ] -} ] - -// 25 -// Input JSON -[ - { - "restaurant": { - "rating": { - "value": 9 - }, - "address": { - "value": "India" - } - }, - "itemsList": [ - { - "itemName": "Example 11", - "itemPrice": 120 - }, - { - "itemName": "Example 12", - "itemPrice": 150 - } - ] - }, - { - "restaurant": { - "rating": { - "value": 7 - }, - "address": { - "value": "United States" - } - }, - "itemsList": [ - { - "itemName": "Example 21", - "itemPrice": 100 - }, - { - "itemName": "Example 22", - "itemPrice": 190 - } - ] - } -] - -// Jolt Spec -[ - { - "operation": "shift", - "spec": { - "*": { - "restaurant": { - "rating": { - "value": "[#4].Restaurant Rating" - }, - "address": { - "value": "[#4].Restaurant Country" - } - }, - "itemsList": { - "*": { - "itemName": "[#4].Dishes.[#2].Dish Name", - "itemPrice": "[#4].Dishes.[#2].Dish Price" - } - } - } - } - } - -] - -// Output JSON -[ { - "Restaurant Rating" : 9, - "Restaurant Country" : "India", - "Dishes" : [ { - "Dish Name" : "Example 11", - "Dish Price" : 120 - }, { - "Dish Name" : "Example 12", - "Dish Price" : 150 - } ] -}, { - "Restaurant Rating" : 7, - "Restaurant Country" : "United States", - "Dishes" : [ { - "Dish Name" : "Example 21", - "Dish Price" : 100 - }, { - "Dish Name" : "Example 22", - "Dish Price" : 190 - } ] -} ] - - -// 26 -// Input Json - -[ - { - "returnId": "10051", - "returnQuantity": 2, - "returnPrice": 100, - "returnTax": 12.56 - }, - { - "returnId": "10052", - "returnQuantity": 25, - "returnPrice": 35, - "returnTax": 29.85 - } -] - -// Json Spec - -[ - { - "operation": "modify-default-beta", - "spec": { - "*": { - "Return Id": "@(1,returnId)", - "temp": "=divide(1,@(1,returnQuantity))", - "Return Amount": "=divideAndRound(2,@(1,returnPrice),@(1,temp))", - "Return Total Amount": "=doubleSum(@(1,Return Amount),@(1,returnTax))" - } - } - }, - { - "operation": "remove", - "spec": { - "*": { - "returnId": "", - "returnQuantity": "", - "returnPrice": "", - "returnTax": "", - "temp": "" - } - } - } -] - -// Output Json - -[ - { - "Return Id": "10051", - "Return Amount": 200.0, - "Return Total Amount": 212.56 - }, - { - "Return Id": "10052", - "Return Amount": 875.0, - "Return Total Amount": 904.85 - } -] - - -// 27 -// Input J son -[ - { - "returnId": "10051", - "returnQuantity": 2, - "returnPrice": 100, - "returnTax": 12.56, - "country": "USA" - }, - { - "returnId": "10052", - "returnQuantity": 25, - "returnPrice": 35, - "returnTax": 29.85, - "country": "CA" - }, - { - "returnId": "10053", - "returnQuantity": 5, - "returnPrice": 55, - "returnTax": 9.85, - "country": "" - } -] - -// Json Spec - -[ - { - "operation": "modify-overwrite-beta", - "spec": { - "*": { - "Return Id": "@(1, returnId)", - "temp": "=divide(1,@(1,returnQuantity))", - "Return Amount": "=divide(@(1,returnPrice),@(1,temp))", - "Return Total Amount": "=doubleSum(@(1,Return Amount),@(1,returnTax))" - }, - "[0]": { - "Country": "United States of America" - }, - "[1]": { - "Country": "Canada" - }, - "[2]": { - "Country": "NA" - } - } - }, - { - "operation": "shift", - "spec": { - "*": { - "returnId": "[#2].Return Id", - "Return Amount": "[#2].Return Amount", - "Return Total Amount": "[#2].Return Total Amount", - "Country": "[#2].Country" - } - } - } -] - - // Output Json - - [ - { - "Return Id": "10051", - "Return Amount": 200.0, - "Return Total Amount": 212.56, - "Country": "United States of America" - }, - { - "Return Id": "10052", - "Return Amount": 875.0, - "Return Total Amount": 904.85, - "Country": "Canada" - }, - { - "Return Id": "10053", - "Return Amount": 275.0, - "Return Total Amount": 284.85, - "Country": "NA" - } -] - -// 28 -// Input Json - -[ - { - "returnId": "151", - "returnItemAdjustments": [ - { - "returnItemSeqId": "00001", - "amount": 28.64, - "returnAdjustmentTypeId": "RET_SALES_TAX_ADJ", - "description": "Return Sales Tax", - "createdDate": null, - "returnId": "151", - "returnAdjustmentId": "", - "comments": "Return Sales Tax", - "shipGroupSeqId": null - }, - { - "returnItemSeqId": "00001", - "amount": 58.64, - "returnAdjustmentTypeId": "RET_SALES_TAX_ADJ", - "description": "Return Sales Tax", - "createdDate": null, - "returnId": "151", - "returnAdjustmentId": "", - "comments": "Return Sales Tax", - "shipGroupSeqId": null - } - ] - }, - { - "returnId": "152", - "returnItemAdjustments": [ - { - "returnItemSeqId": "00002", - "amount": 38.64, - "returnAdjustmentTypeId": "RET_SALES_TAX_ADJ", - "description": "Return Sales Tax", - "createdDate": null, - "returnId": "152", - "returnAdjustmentId": "", - "comments": "Return Sales Tax", - "shipGroupSeqId": null - } - ] - } -] - -// Json Spec - -[ - { - "operation": "shift", - "spec": { - "*": { - "returnId": "[#2].returnId", - "returnItemAdjustments": { - "*": { - "amount": "[#4].returnTax" - } - } - } - } - }, - { - "operation": "modify-overwrite-beta", - "spec": { - "*": { - "returnTax": "=doubleSum(@(1,returnTax))" - } - } - } -] - -// Output Json - -[ - { - "returnId": "151", - "returnTax": 87.28 - }, - { - "returnId": "152", - "returnTax": 38.64 - } -] -// 29 -// Input Json - -{ - "person": { - "name": "John Doe", - "age": 30, - "address": { - "city": "New York", - "state": "NY" - } - } -} - -// Json Spec - -[ - { - "operation": "shift", - "spec": { - "person": { - "name": "person_name", - "age": "person_age", - "address": { - "city": "person_address_city", - "state": "person_address_state" - } - } - } - } - ] - -// Output Json - -{ - "person_name": "John Doe", - "person_age": 30, - "person_address_city": "New York", - "person_address_state": "NY" -} - -// 30 -// Input Json - -{ - "person": { - "name": "John Doe", - "age": 30, - "address": { - "city": "New York", - "state": "NY" - } - }, - "employee": { - "name": "Jane Doe", - "salary": 50000, - "office": { - "city": "San Francisco", - "state": "CA" - } - } -} - -// Json Spec - -[ - { - "operation": "shift", - "spec": { - "person": { - "name": "&" - }, - "employee": { - "office": { - "*": "office-&" - } - } - } - } - ] - -// Output Json - -{ - "name": "John Doe", - "office-city": "San Francisco", - "office-state": "CA" -} - - -// 31 -// Input Json -{ - "items": [ - { - "id": "1", - "name": "Book", - "prices": [ - { - "currency": "USD", - "value": 10 - }, - { - "currency": "EUR", - "value": 8 - } - ] - }, - { - "id": "2", - "name": "Pen", - "prices": [ - { - "currency": "USD", - "value": 2 - }, - { - "currency": "EUR", - "value": 1.5 - } - ] - } - ] -} - -// Json Spec -[ - { - "operation": "modify-default-beta", - "spec": { - "items": { - "*": { - "prices": { - "*": { - "temp": "=concat(@(3,id),'_',@(1,currency))" - } - } - } - } - } - }, - { - "operation": "shift", - "spec": { - "items": { - "*": { - "prices": { - "*": { - "@value": "@temp" - } - } - } - } - } - } -] - -// Output Json -{ - "1_USD": 10, - "1_EUR": 8, - "2_USD": 2, - "2_EUR": 1.5 -} -// 32 -// Input JSON -{ - "data": [ - { - "x": "A", - "y": "1", - "value": 10 - }, - { - "x": "A", - "y": "2", - "value": 20 - }, - { - "x": "B", - "y": "1", - "value": 30 - }, - { - "x": "B", - "y": "2", - "value": 40 - } - ] -} - -// JSON spec - -[ - { - "operation": "shift", - "spec": { - "data": { - "*": { - "value": "@(1,x).@(1,y)" - } - } - } - } -] -// Output JSON -{ - "A" : { - "1" : 10, - "2" : 20 - }, - "B" : { - "1" : 30, - "2" : 40 - } -} -// 33 -// Input Json - -{ - "id": 1, - "name": "John", - "hobbies": [ - { - "name": "reading", - "level": "advanced" - }, - { - "name": "swimming", - "level": "beginner" - } - ] -} - - -// Json Spec - -[ - { - "operation": "modify-overwrite-beta", - "spec": { - "hobbies": { - "*": { - "id": "@(3,id)", - "name": "@(3,name)", - "hobby_level": "@(1,level)", - "hobby_name": "@(1,name)" - } - } - } - }, - { - "operation": "shift", - "spec": { - "hobbies": { - "*": "[#1]" - } - } - }, - { - "operation": "remove", - "spec": { - "*": { - "level": "" - } - } - } -] - -// Output Json - -[ - { - "name": "John", - "id": 1, - "hobby_level": "advanced", - "hobby_name": "John" - }, - { - "name": "John", - "id": 1, - "hobby_level": "beginner", - "hobby_name": "John" - } -] - -// 34 -// Input JSON -{ - "name": "John", - "hobby_1": "reading", - "level_1": "advanced", - "hobby_2": "swimming", - "level_2": "beginner" -} - -// JSON spec -[ - - { - "operation": "shift", - "spec": { - "name": "&", - "hobby_1": "hobbies[0].name", - "level_1": "hobbies[0].level", - "hobby_2": "hobbies[1].name", - "level_2": "hobbies[1].level" - } - } -] - -// output json -{ - "name": "John", - "hobbies": [ - { - "name": "reading", - "level": "advanced" - }, - { - "name": "swimming", - "level": "beginner" - } - ] -} \ No newline at end of file diff --git a/Module 5/Problem_1/Q1.json b/Module 5/Problem_1/Q1.json new file mode 100644 index 00000000..312aac28 --- /dev/null +++ b/Module 5/Problem_1/Q1.json @@ -0,0 +1,182 @@ +Input: +{ + "orders": [ + { + "orderId": 1, + "orderDate": "2022-02-20T12:34:56Z", + "customer": { + "customerId": 1, + "firstName": "John", + "lastName": "Doe", + "email": "johndoe@example.com", + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + } + }, + "items": [ + { + "itemId": 1, + "name": "Product A", + "quantity": 2, + "price": 10 + }, + { + "itemId": 2, + "name": "Product B", + "quantity": 1, + "price": 20 + } + ] + }, + { + "orderId": 2, + "orderDate": "2022-02-21T09:12:34Z", + "customer": { + "customerId": 2, + "firstName": "Jane", + "lastName": "Smith", + "email": "janesmith@example.com", + "address": { + "street": "456 Oak St", + "city": "Somewhere", + "state": "NY", + "zip": "67890" + } + }, + "items": [ + { + "itemId": 3, + "name": "Product C", + "quantity": 3, + "price": 15 + } + ] + } + ] +} + +json Spec: +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "orders": { + "*": { + "customer": { + "address": "=concat(@(1,address.street),' ',@(1,address.city), ' ', @(1,address.state), ' ',@(1,address.zip))", + "fullname": "=concat(@(1,firstName),' ',@(1,lastName))" + }, + "itemTemp": "@(1,items)" + } + } + } + }, + + { + "operation": "modify-overwrite-beta", + "spec": { + "orders": { + "*": { + "itemTemp": { + "*": { + "inverseValue": "=divide(1,@(1,price))", + "temp": "=divideAndRound(2, @(1,quantity), @(1,inverseValue))" + } + } + } + } + } + }, + { + "operation": "shift", + "spec": { + "orders": { + "*": { + "*": "orders[&1].&", + "itemTemp": { + "*": { + "temp": "orders[#4].total" + } + } + } + } + } + }, + { + "operation": "modify-overwrite-beta", + "spec": { + "orders": { + "*": { + "total": "=doubleSum(@(1,total))" + } + } + } + }, + + { + "operation": "remove", + "spec": { + "orders": { + "*": { + "items": { + "*": { + "inverseValue": "", + "temp": "" + } + }, + "customer": { + "firstName": "", + "lastName": "" + } + } + } + } + } +] + +Output: +{ + "orders" : [ { + "orderId" : 1, + "orderDate" : "2022-02-20T12:34:56Z", + "customer" : { + "customerId" : 1, + "firstName" : "John", + "lastName" : "Doe", + "email" : "johndoe@example.com", + "address" : "123 Main St Anytown CA 12345" + }, + "items" : [ { + "itemId" : 1, + "name" : "Product A", + "quantity" : 2, + "price" : 10 + }, { + "itemId" : 2, + "name" : "Product B", + "quantity" : 1, + "price" : 20 + } ], + "total" : 40.0 + }, { + "orderId" : 2, + "orderDate" : "2022-02-21T09:12:34Z", + "customer" : { + "customerId" : 2, + "firstName" : "Jane", + "lastName" : "Smith", + "email" : "janesmith@example.com", + "address" : "456 Oak St Somewhere NY 67890" + }, + "items" : [ { + "itemId" : 3, + "name" : "Product C", + "quantity" : 3, + "price" : 15 + } ], + "total" : 45.0 + } ] +} \ No newline at end of file diff --git a/Module 5/Problem_1/approach.md b/Module 5/Problem_1/approach.md new file mode 100644 index 00000000..2957b76e --- /dev/null +++ b/Module 5/Problem_1/approach.md @@ -0,0 +1,8 @@ +### Number of operations: 5 +1. modify-overwrite-beta +2. shift +3. remove +### Approach +1. The modify-overwrite-beta is used in order to concatenate the firstName and the lastName and the complete address into a single string. Also the modify-overwrite-beta operation is used to create a key value pair that gives us the total of orders by using the divide and doubleSum functions. +2. The shift operation is then used in order to get the desired output in that particular order. +3. Finally the remove operation is used to remove all the temp variables that were created during the calculation of the total amount of orders. \ No newline at end of file diff --git a/Module 5/Problem_10/Q10.json b/Module 5/Problem_10/Q10.json new file mode 100644 index 00000000..92fbc12d --- /dev/null +++ b/Module 5/Problem_10/Q10.json @@ -0,0 +1,70 @@ +Input JSON +{ + "name": "John Smith", + "age": 35, + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + }, + "phone_numbers": [ + { + "type": "home", + "number": "555-1234" + }, + { + "type": "work", + "number": "555-5678" + } + ] +} + +Jolt Spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "fullName": "=split(' ',@(2,name))", + "first_name": "=firstElement(@(1,fullName))", + "last_name": "=lastElement(@(1,fullName))", + "phone_number_count": "=size(@(1,phone_numbers))" + } + }, + { + "operation": "shift", + "spec": { + "first_name": "&", + "last_name": "&", + "age": "&", + "address": "&", + "phone_numbers": "&", + "phone_number_count": "&" + } + } + +] + +Output JSON +{ + "first_name": "John", + "last_name": "Smith", + "age": 35, + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + }, + "phone_numbers": [ + { + "type": "home", + "number": "555-1234" + }, + { + "type": "work", + "number": "555-5678" + } + ], + "phone_number_count": 2 +} \ No newline at end of file diff --git a/Module 5/Problem_10/approach.md b/Module 5/Problem_10/approach.md new file mode 100644 index 00000000..cc0044f9 --- /dev/null +++ b/Module 5/Problem_10/approach.md @@ -0,0 +1,7 @@ +### Number of operations: 2 +1. modify-overwrite-beta +2. shift + +### Approach +1. The modify-overwrite-beta is used in order to split the name in the input json and to add the count of the phone_numbers. +2. Finally, in the second operation i.e. shift operartion the json is transformed into the desired struture. \ No newline at end of file diff --git a/Module 5/Problem_11/Q11.json b/Module 5/Problem_11/Q11.json new file mode 100644 index 00000000..e2e2b582 --- /dev/null +++ b/Module 5/Problem_11/Q11.json @@ -0,0 +1,41 @@ +Input JSON +{ + "items": [ + { + "name": "item1", + "value": 10 + }, + { + "name": "item2", + "value": 20 + } + ] +} + +Jolt Spec +[ + + { + "operation": "shift", + "spec": { + "items": { + "*": { + "name": "items[#2].itemName", + "value": "items[#2].itemValue" + } + } + } + } + +] + +Output JSON +{ + "items" : [ { + "itemName" : "item1", + "itemValue" : 10 + }, { + "itemName" : "item2", + "itemValue" : 20 + } ] +} \ No newline at end of file diff --git a/Module 5/Problem_11/approach.md b/Module 5/Problem_11/approach.md new file mode 100644 index 00000000..a92c3a07 --- /dev/null +++ b/Module 5/Problem_11/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. Shift + +### Approach +1. The shift operation is used in order to change the keys. \ No newline at end of file diff --git a/Module 5/Problem_12/Q_12.json b/Module 5/Problem_12/Q_12.json new file mode 100644 index 00000000..7cdc0bdd --- /dev/null +++ b/Module 5/Problem_12/Q_12.json @@ -0,0 +1,63 @@ +Input JSON +{ + "employee": { + "firstName": "John", + "lastName": "Doe", + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + }, + "phones": [ + { + "type": "home", + "number": "555-555-1234" + }, + { + "type": "work", + "number": "555-555-5678" + } + ] + } +} + +Jolt Spec +[ + + { + "operation": "modify-overwrite-beta", + "spec": { + "employee": { + "name": "=concat(@(1,firstName),' ', @(1,lastName))", + "address": "=concat(@(1,address.street),' ', @(1,address.city),' ', @(1,address.state),' ', @(1,address.zip))" + } + } + }, + { + "operation": "shift", + "spec": { + "employee": { + "name": "name", + "address": "&", + "phones": "phoneNumbers" + } + } + } +] + +Output JSON +{ + "name": "John Doe", + "address": "123 Main St, Anytown, CA 12345", + "phoneNumbers": [ + { + "type": "home", + "number": "555-555-1234" + }, + { + "type": "work", + "number": "555-555-5678" + } + ] +} \ No newline at end of file diff --git a/Module 5/Problem_12/approach.md b/Module 5/Problem_12/approach.md new file mode 100644 index 00000000..1bba50cd --- /dev/null +++ b/Module 5/Problem_12/approach.md @@ -0,0 +1,7 @@ +### Number of operations: 2 +1. modify-overwrite-beta +2. shift + +### Approach +1. The modify-overwrite-beta is used along with the concat function to concatenate the firstName & lastName and the various values in the address field. +2. The shift operation is then used transform the structure of the input json into the desired output json. \ No newline at end of file diff --git a/Module 5/Problem_13/Q13.json b/Module 5/Problem_13/Q13.json new file mode 100644 index 00000000..e20a1b37 --- /dev/null +++ b/Module 5/Problem_13/Q13.json @@ -0,0 +1,53 @@ + Input JSON +{ + "employees": [ + { + "id": "001", + "name": "John", + "department": "HR" + }, + { + "id": "002", + "name": "Jane", + "department": "Sales" + }, + { + "id": "003", + "name": "Bob", + "department": "IT" + } + ] + } + JOLT Spec + [ + { + "operation": "shift", + "spec": { + "employees": { + "*": { + "name": "employees.@(1,id).&", + "department": "employees.@(1,id).&" + } + } + } + } + ] + + Output JSON + { + "employees" : { + "001" : { + "name" : "John", + "department" : "HR" + }, + "002" : { + "name" : "Jane", + "department" : "Sales" + }, + "003" : { + "name" : "Bob", + "department" : "IT" + } + } + } + \ No newline at end of file diff --git a/Module 5/Problem_13/approach.md b/Module 5/Problem_13/approach.md new file mode 100644 index 00000000..3ee3f8c6 --- /dev/null +++ b/Module 5/Problem_13/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. shift + +### Approach +1. The shift operation is used to transform the input json into the outuput json. \ No newline at end of file diff --git a/Module 5/Problem_14/Q14.json b/Module 5/Problem_14/Q14.json new file mode 100644 index 00000000..f1e34df1 --- /dev/null +++ b/Module 5/Problem_14/Q14.json @@ -0,0 +1,83 @@ +Input Json +{ + "employees": [ + { + "id": "001", + "name": "John", + "department": "HR", + "phone": [ + { + "type": "home", + "number": "555-555-1234" + }, + { + "type": "work", + "number": "555-555-5678" + } + ] + }, + { + "id": "002", + "name": "Jane", + "department": "Sales", + "phone": [ + { + "type": "home", + "number": "555-555-4567" + }, + { + "type": "work", + "number": "555-555-8901" + } + ] + } + ] +} + +Json Spec +[ + { + "operation": "shift", + "spec": { + "employees": { + "*": { + "id": "employees.[#2].&", + "name": "employees.[#2].&", + "phone": { + "*": { + "@number": "employees.[#4].@type" + } + } + } + } + } + }, + { + "operation": "shift", + "spec": { + "employees": { + "*": { + "*": "[#2].&", + "home": "[#2].homePhone", + "work": "[#2].workPhone" + } + } + } + } +] + +Ouput Json +[ + { + "id": "001", + "name": "John", + "homePhone": "555-555-1234", + "workPhone": "555-555-5678" + }, + { + "id": "002", + "name": "Jane", + "homePhone": "555-555-4567", + "workPhone": "555-555-8901" + } +] \ No newline at end of file diff --git a/Module 5/Problem_14/approach.md b/Module 5/Problem_14/approach.md new file mode 100644 index 00000000..9356bed9 --- /dev/null +++ b/Module 5/Problem_14/approach.md @@ -0,0 +1,6 @@ +### Number of operations: 2 +1. shift + +### Approach +1. The first shift operation is used to transform the input json into the outuput json. +2. The second shift operation is used to change the name of the home and work field into homePhone and workPhone. \ No newline at end of file diff --git a/Module 5/Problem_15/Q15.json b/Module 5/Problem_15/Q15.json new file mode 100644 index 00000000..d8e1830b --- /dev/null +++ b/Module 5/Problem_15/Q15.json @@ -0,0 +1,190 @@ +Input: +{ + "orders": [ + { + "id": "order1", + "date": "2022-01-01T00:00:00Z", + "customerId": "customer1", + "items": [ + { + "id": "item1", + "name": "Product 1", + "price": 10, + "quantity": 2 + }, + { + "id": "item2", + "name": "Product 2", + "price": 20, + "quantity": 1 + } + ], + "totalPrice": 40 + }, + { + "id": "order2", + "date": "2022-02-01T00:00:00Z", + "customerId": "customer1", + "items": [ + { + "id": "item3", + "name": "Product 3", + "price": 30, + "quantity": 3 + } + ], + "totalPrice": 90 + }, + { + "id": "order3", + "date": "2022-03-01T00:00:00Z", + "customerId": "customer2", + "items": [ + { + "id": "item4", + "name": "Product 4", + "price": 40, + "quantity": 4 + } + ], + "totalPrice": 160 + } + ] +} + +Json spec +[ + { + "operation": "shift", + "spec": { + "orders": { + "*": { + "@": "@(1,customerId).orders[]" + } + } + } + }, + { + "operation": "shift", + "spec": { + "*": "customers" + } + }, + { + "operation": "shift", + "spec": { + "customers": { + "*": { + "orders": { + "*": { + "*": "customers[#4].orders[#2].&", + "totalPrice": "customers[#4].totalAmount" + } + } + } + } + } + }, + { + "operation": "modify-overwrite-beta", + "spec": { + "customers": { + "*": { + "totalAmount": "=intSum(@(1,totalAmount))", + "id": "@(1,orders[0].customerId)" + }, + "[0]": { + "name": "John Doe" + }, + "[1]": { + "name": "Jane Doe" + } + } + } + }, + { + "operation": "remove", + "spec": { + "customers": { + "*": { + "orders": { + "*": { + "customerId": "" + } + } + } + } + } + }, + { + "operation": "sort" + } +] + + + +Output: +{ + "customers": [ + { + "id": "customer1", + "name": "John Smith", + "totalAmount": 130, + "orders": [ + { + "id": "order1", + "date": "2022-01-01T00:00:00Z", + "items": [ + { + "id": "item1", + "name": "Product 1", + "price": 10, + "quantity": 2 + }, + { + "id": "item2", + "name": "Product 2", + "price": 20, + "quantity": 1 + } + ], + "totalPrice": 40 + }, + { + "id": "order2", + "date": "2022-02-01T00:00:00Z", + "items": [ + { + "id": "item3", + "name": "Product 3", + "price": 30, + "quantity": 3 + } + ], + "totalPrice": 90 + } + ] + }, + { + "id": "customer2", + "name": "Jane Doe", + "totalAmount": 160, + "orders": [ + { + "id": "order3", + "date": "2022-03-01T00:00:00Z", + "items": [ + { + "id": "item4", + "name": "Product 4", + "price": 40, + "quantity": 4 + } + ], + "totalPrice": 160 + } + ] + } + ] +} + diff --git a/Module 5/Problem_15/approach.md b/Module 5/Problem_15/approach.md new file mode 100644 index 00000000..9a8b40e0 --- /dev/null +++ b/Module 5/Problem_15/approach.md @@ -0,0 +1,11 @@ +### Number of operations: 5 +1. shift +2. modify-overwrite-beta +3. remove +4. sort + +### Approach +1. the shift operation is used to transform the input json into required output json. +2. the modify-overwrite-beta is used to calculate the total of the orders by using the divide and doubleSum functions. +3. the remove operation is used in order to remove the extra temp variables that were created during the calculation process of the total amount. +4. finally, the sort operation is used to sort the output json in order to match the requirements. \ No newline at end of file diff --git a/Module 5/Problem_16/Q16.json b/Module 5/Problem_16/Q16.json new file mode 100644 index 00000000..56f343ee --- /dev/null +++ b/Module 5/Problem_16/Q16.json @@ -0,0 +1,69 @@ +Input Json +{ + "employees": [ + { + "id": "1001", + "name": "John Doe", + "age": 25, + "skills": [ + { + "name": "Java", + "level": "Intermediate" + }, + { + "name": "Python", + "level": "Expert" + } + ] + }, + { + "id": "1002", + "name": "Jane Doe", + "age": 30, + "skills": [ + { + "name": "Java", + "level": "Expert" + } + ] + } + ] +} + +JSON Spec + +[ + { + "operation": "shift", + "spec": { + "employees": { + "*": { + "skills": { + "*": { + "@(2,name)": "@name.@level[]" + } + } + } + } + } + } + ] + + +Output +{ + "Java": { + "Intermediate": [ + "John Doe" + ], + "Expert": [ + "Jane Doe", + "John Doe" + ] + }, + "Python": { + "Expert": [ + "John Doe" + ] + } +} \ No newline at end of file diff --git a/Module 5/Problem_16/approach.md b/Module 5/Problem_16/approach.md new file mode 100644 index 00000000..3ee3f8c6 --- /dev/null +++ b/Module 5/Problem_16/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. shift + +### Approach +1. The shift operation is used to transform the input json into the outuput json. \ No newline at end of file diff --git a/Module 5/Problem_17/Q17.json b/Module 5/Problem_17/Q17.json new file mode 100644 index 00000000..64a5e538 --- /dev/null +++ b/Module 5/Problem_17/Q17.json @@ -0,0 +1,61 @@ +Input JSON + +{ + "products": [ + { + "id": "1001", + "name": "Product 1", + "price": 10.99 + }, + { + "id": "1002", + "name": "Product 2", + "price": 15.99, + "available": true + }, + { + "id": "1003", + "name": "Product 3", + "price": 20.99, + "available": false + } + ] +} + +// Jolt Spec +[ + { + "operation": "modify-default-beta", + "spec": { + "products": { + "*": { + "available": "false" + } + } + } + } +] + +// Output JSON +{ + "products": [ + { + "id": "1001", + "name": "Product 1", + "price": 10.99, + "available": false + }, + { + "id": "1002", + "name": "Product 2", + "price": 15.99, + "available": true + }, + { + "id": "1003", + "name": "Product 3", + "price": 20.99, + "available": false + } + ] +} \ No newline at end of file diff --git a/Module 5/Problem_17/approach.md b/Module 5/Problem_17/approach.md new file mode 100644 index 00000000..65961086 --- /dev/null +++ b/Module 5/Problem_17/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. modify-default-beta + +### Approach +1. The modify-default-beta operation is used to add the available:false key-value as a default field to all the objects in the products list. \ No newline at end of file diff --git a/Module 5/Problem_18/Q18.json b/Module 5/Problem_18/Q18.json new file mode 100644 index 00000000..dd2cc220 --- /dev/null +++ b/Module 5/Problem_18/Q18.json @@ -0,0 +1,61 @@ +Input JSON +{ + "employees": [ + { + "name": "John", + "age": 30, + "salary": 5000 + }, + { + "name": "Jane", + "age": 35, + "salary": 6000 + }, + { + "name": "Bob", + "age": 40, + "salary": 7000 + } + ] +} + +Jolt Spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "employees": { + "*": { + "temp": "=divideAndRound(0,@(1,salary),10)", + "salary": "=doubleSum(@(1,salary),@(1,temp))" + } + } + } + }, + { + "operation": "remove", + "spec": { + "temp": "" + } + } +] + +Output JSON +{ + "employees" : [ { + "name" : "John", + "age" : 30, + "salary" : 5500.0, + "temp" : 500.0 + }, { + "name" : "Jane", + "age" : 35, + "salary" : 6600.0, + "temp" : 600.0 + }, { + "name" : "Bob", + "age" : 40, + "salary" : 7700.0, + "temp" : 700.0 + } ] +} \ No newline at end of file diff --git a/Module 5/Problem_18/approach.md b/Module 5/Problem_18/approach.md new file mode 100644 index 00000000..b3393177 --- /dev/null +++ b/Module 5/Problem_18/approach.md @@ -0,0 +1,7 @@ +### Number of operations: 2 +1. modify-overwrite-beta +2. remove + +### Approach +1. The modify-overwrite-beta operation is used to increment the salary of each employee by 10% with the help of a temp variable and divide and intSum functions. +2. Finally, the remove operation is used to remove the extra temp variable that was created during the modify-overwrite-beta operation. \ No newline at end of file diff --git a/Module 5/Problem_19/Q_19.json b/Module 5/Problem_19/Q_19.json new file mode 100644 index 00000000..232dadd5 --- /dev/null +++ b/Module 5/Problem_19/Q_19.json @@ -0,0 +1,63 @@ +Input Json + +{ + "products": [ + { + "id": "1001", + "name": "Product 1", + "price": 10.99 + }, + { + "id": "1002", + "name": "Product 2", + "price": 15.99 + }, + { + "id": "1003", + "name": "Product 3", + "price": 20.99 + } + ] +} + +Json Spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "products": { + "*": { + "price": "=doubleSum(@(1,price),@(1,price))" + } + } + } + }, + { + "operation": "modify-overwrite-beta", + "spec": { + "products": { + "[0]": { + "price": "=divide(@(1,price),2)" + } + } + } + } +] +Output Json + +{ + "products" : [ { + "id" : "1001", + "name" : "Product 1", + "price" : 10.99 + }, { + "id" : "1002", + "name" : "Product 2", + "price" : 31.98 + }, { + "id" : "1003", + "name" : "Product 3", + "price" : 41.98 + } ] + } + \ No newline at end of file diff --git a/Module 5/Problem_19/approach.md b/Module 5/Problem_19/approach.md new file mode 100644 index 00000000..bf405ebe --- /dev/null +++ b/Module 5/Problem_19/approach.md @@ -0,0 +1,7 @@ +### Number of operations: 2 +1. modify-overwrite-beta + + +### Approach +1. The first modify-overwrite-beta operation used to double the price of every product in the products list. +2. Then the second modify-overwrite-beta is used to divide the price of product with product id 1001 to keep it the way it was. \ No newline at end of file diff --git a/Module 5/Problem_2/Q2.json b/Module 5/Problem_2/Q2.json new file mode 100644 index 00000000..23d9bb53 --- /dev/null +++ b/Module 5/Problem_2/Q2.json @@ -0,0 +1,25 @@ +Input JSON +{ + "name": "John", + "age": 35, + "city": "New York" +} + +Transformation Jolt +[ + { + "operation": "shift", + "spec": { + "name": "Name", + "age": "Age", + "city": "City" + } + } +] + +Output JSON +{ + "Name": "John", + "Age": 35, + "City": "New York" +} diff --git a/Module 5/Problem_2/approach.md b/Module 5/Problem_2/approach.md new file mode 100644 index 00000000..a92c3a07 --- /dev/null +++ b/Module 5/Problem_2/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. Shift + +### Approach +1. The shift operation is used in order to change the keys. \ No newline at end of file diff --git a/Module 5/Problem_20/Q20.json b/Module 5/Problem_20/Q20.json new file mode 100644 index 00000000..d3a49008 --- /dev/null +++ b/Module 5/Problem_20/Q20.json @@ -0,0 +1,112 @@ +Input Json + +{ + "employees": [ + { + "name": "John", + "age": 30, + "department": { + "id": 1, + "name": "Sales" + } + }, + { + "name": "Jane", + "age": 35, + "department": { + "id": 2, + "name": "Marketing" + } + }, + { + "name": "Bob", + "age": 40, + "department": { + "id": 1, + "name": "Sales" + } + } + ] +} + +Json Spec + +[ + { + "operation": "shift", + "spec": { + "employees": { + "*": { + "@department": "departments.[&]", + "name": "departments[#2].employees.name", + "age": "departments[#2].employees.age" + } + } + } + }, + { + "operation": "shift", + "spec": { + "departments": { + "*": { + "id": "departments.@(1,id).id", + "name": "departments.@(1,id).name", + "employees": "departments.@(1,id).employees[]" + } + } + } + }, + { + "operation": "shift", + "spec": { + "departments": { + "*": "departments" + } + } + }, + { + "operation": "modify-overwrite-beta", + "spec": { + "departments": { + "*": { + "*": { + "employees": "&" + }, + "id": "@(1,id[0])", + "name": "@(1,name[0])" + } + } + } + } +] + +Output Json + + { + "departments": [ + { + "id": 1, + "name": "Sales", + "employees": [ + { + "name": "John", + "age": 30 + }, + { + "name": "Bob", + "age": 40 + } + ] + }, + { + "id": 2, + "name": "Marketing", + "employees": [ + { + "name": "Jane", + "age": 35 + } + ] + } + ] +} \ No newline at end of file diff --git a/Module 5/Problem_20/approach.md b/Module 5/Problem_20/approach.md new file mode 100644 index 00000000..7766808e --- /dev/null +++ b/Module 5/Problem_20/approach.md @@ -0,0 +1,8 @@ +### Number of operations: 5 +1. shift +2. modify-overwrite-beta + + +### Approach +1. the shift operation is used to transform the input json into required output json. +2. the modify-overwrite-beta is used to calculate the total of the orders by using the divide and doubleSum functions. diff --git a/Module 5/Problem_21/Q21.json b/Module 5/Problem_21/Q21.json new file mode 100644 index 00000000..39fb640f --- /dev/null +++ b/Module 5/Problem_21/Q21.json @@ -0,0 +1,30 @@ +Input JSON +{ + "restaurant": { + "rating": { + "value": 3 + }, + "address": { + "value": "India" + } + } +} + +Jolt Spec +[ + { + "operation": "shift", + "spec": { + "restaurant": { + "rating": { + "value": "Restaurant Rating" + } + } + } + } +] + +Output JSON +{ + "Restaurant Rating" : 3 +} \ No newline at end of file diff --git a/Module 5/Problem_21/approach.md b/Module 5/Problem_21/approach.md new file mode 100644 index 00000000..df57fbde --- /dev/null +++ b/Module 5/Problem_21/approach.md @@ -0,0 +1,6 @@ +### Number of operations: 1 +1. shift + + +### Approach +1. A simple shift operator is sufficient to transform the given input json into the required output. \ No newline at end of file diff --git a/Module 5/Problem_22/Q22.json b/Module 5/Problem_22/Q22.json new file mode 100644 index 00000000..c71a98d2 --- /dev/null +++ b/Module 5/Problem_22/Q22.json @@ -0,0 +1,46 @@ +Input JSON +[ + { + "restaurant": { + "rating": { + "value": 9 + }, + "address": { + "value": "India" + } + } + }, + { + "restaurant": { + "rating": { + "value": 7 + }, + "address": { + "value": "United States" + } + } + } +] + +Jolt Spec +[ + { + "operation": "shift", + "spec": { + "*": { + "restaurant": { + "rating": { + "value": "[#4].Restaurant Rating" + } + } + } + } + } +] + +Output JSON +[ { + "Restaurant Rating" : 9 +}, { + "Restaurant Rating" : 7 +} ] \ No newline at end of file diff --git a/Module 5/Problem_22/approach.md b/Module 5/Problem_22/approach.md new file mode 100644 index 00000000..9a07ec68 --- /dev/null +++ b/Module 5/Problem_22/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. shift + +### Approach +1. A simple shift operator is sufficient to transform the given input json into the required output. \ No newline at end of file diff --git a/Module 5/Problem_23/Q23.json b/Module 5/Problem_23/Q23.json new file mode 100644 index 00000000..0d7d2711 --- /dev/null +++ b/Module 5/Problem_23/Q23.json @@ -0,0 +1,51 @@ +Input Json +[ + { + "restaurant": { + "rating": { + "value": 9 + }, + "address": { + "value": "India" + } + } + }, + { + "restaurant": { + "rating": { + "value": 7 + }, + "address": { + "value": "United States" + } + } + } + ] + +Jolt spec + [ + { + "operation": "shift", + "spec": { + "*": { + "restaurant": { + "rating": { + "value": "[#4].Restaurant Rating" + }, + "address": { + "value": "[#4].Restaurant Country" + } + } + } + } + } + ] + + Output JSON + [ { + "Restaurant Rating" : 9, + "Restaurant Country" : "India" + }, { + "Restaurant Rating" : 7, + "Restaurant Country" : "United States" + } ] \ No newline at end of file diff --git a/Module 5/Problem_23/approach.md b/Module 5/Problem_23/approach.md new file mode 100644 index 00000000..9a07ec68 --- /dev/null +++ b/Module 5/Problem_23/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. shift + +### Approach +1. A simple shift operator is sufficient to transform the given input json into the required output. \ No newline at end of file diff --git a/Module 5/Problem_24/Q24.json b/Module 5/Problem_24/Q24.json new file mode 100644 index 00000000..852d8b75 --- /dev/null +++ b/Module 5/Problem_24/Q24.json @@ -0,0 +1,82 @@ +Input JSON +[ + { + "restaurant": { + "rating": { + "value": 9 + }, + "address": { + "value": "India" + } + }, + "itemsList": [ + { + "itemName": "Example 11", + "itemPrice": 120 + }, + { + "itemName": "Example 12", + "itemPrice": 150 + } + ] + }, + { + "restaurant": { + "rating": { + "value": 7 + }, + "address": { + "value": "United States" + } + }, + "itemsList": [ + { + "itemName": "Example 21", + "itemPrice": 100 + }, + { + "itemName": "Example 22", + "itemPrice": 190 + } + ] + } +] + +Jolt Spec +[ + { + "operation": "shift", + "spec": { + "*": { + "restaurant": { + "rating": { + "value": "[#4].Restaurant Rating" + }, + "address": { + "value": "[#4].Restaurant Country" + } + }, + "itemsList": { + "*": { + "itemName": "[#4].Dish Name", + "itemPrice": "[#4].Dish Price" + } + } + } + } + } + +] + +Output Json +[ { + "Restaurant Rating" : 9, + "Restaurant Country" : "India", + "Dish Name" : [ "Example 11", "Example 12" ], + "Dish Price" : [ 120, 150 ] +}, { + "Restaurant Rating" : 7, + "Restaurant Country" : "United States", + "Dish Name" : [ "Example 21", "Example 22" ], + "Dish Price" : [ 100, 190 ] +} ] \ No newline at end of file diff --git a/Module 5/Problem_24/approach.md b/Module 5/Problem_24/approach.md new file mode 100644 index 00000000..43a8e233 --- /dev/null +++ b/Module 5/Problem_24/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. shift + +### Approach +1. The shift operation is used along with the '#' wildcard to determine the level at which we want the output. \ No newline at end of file diff --git a/Module 5/Problem_25/Q25.json b/Module 5/Problem_25/Q25.json new file mode 100644 index 00000000..30008ef9 --- /dev/null +++ b/Module 5/Problem_25/Q25.json @@ -0,0 +1,92 @@ +Input JSON +[ + { + "restaurant": { + "rating": { + "value": 9 + }, + "address": { + "value": "India" + } + }, + "itemsList": [ + { + "itemName": "Example 11", + "itemPrice": 120 + }, + { + "itemName": "Example 12", + "itemPrice": 150 + } + ] + }, + { + "restaurant": { + "rating": { + "value": 7 + }, + "address": { + "value": "United States" + } + }, + "itemsList": [ + { + "itemName": "Example 21", + "itemPrice": 100 + }, + { + "itemName": "Example 22", + "itemPrice": 190 + } + ] + } +] + +// Jolt Spec +[ + { + "operation": "shift", + "spec": { + "*": { + "restaurant": { + "rating": { + "value": "[#4].Restaurant Rating" + }, + "address": { + "value": "[#4].Restaurant Country" + } + }, + "itemsList": { + "*": { + "itemName": "[#4].Dishes.[#2].Dish Name", + "itemPrice": "[#4].Dishes.[#2].Dish Price" + } + } + } + } + } + +] + +// Output JSON +[ { + "Restaurant Rating" : 9, + "Restaurant Country" : "India", + "Dishes" : [ { + "Dish Name" : "Example 11", + "Dish Price" : 120 + }, { + "Dish Name" : "Example 12", + "Dish Price" : 150 + } ] +}, { + "Restaurant Rating" : 7, + "Restaurant Country" : "United States", + "Dishes" : [ { + "Dish Name" : "Example 21", + "Dish Price" : 100 + }, { + "Dish Name" : "Example 22", + "Dish Price" : 190 + } ] +} ] diff --git a/Module 5/Problem_25/approach.md b/Module 5/Problem_25/approach.md new file mode 100644 index 00000000..43a8e233 --- /dev/null +++ b/Module 5/Problem_25/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. shift + +### Approach +1. The shift operation is used along with the '#' wildcard to determine the level at which we want the output. \ No newline at end of file diff --git a/Module 5/Problem_26/Q26.json b/Module 5/Problem_26/Q26.json new file mode 100644 index 00000000..0624c8d9 --- /dev/null +++ b/Module 5/Problem_26/Q26.json @@ -0,0 +1,56 @@ +Input Json +[ + { + "returnId": "10051", + "returnQuantity": 2, + "returnPrice": 100, + "returnTax": 12.56 + }, + { + "returnId": "10052", + "returnQuantity": 25, + "returnPrice": 35, + "returnTax": 29.85 + } +] + +Json Spec +[ + { + "operation": "modify-default-beta", + "spec": { + "*": { + "Return Id": "@(1,returnId)", + "temp": "=divide(1,@(1,returnQuantity))", + "Return Amount": "=divideAndRound(2,@(1,returnPrice),@(1,temp))", + "Return Total Amount": "=doubleSum(@(1,Return Amount),@(1,returnTax))" + } + } + }, + { + "operation": "remove", + "spec": { + "*": { + "returnId": "", + "returnQuantity": "", + "returnPrice": "", + "returnTax": "", + "temp": "" + } + } + } +] + +Output Json +[ + { + "Return Id": "10051", + "Return Amount": 200.0, + "Return Total Amount": 212.56 + }, + { + "Return Id": "10052", + "Return Amount": 875.0, + "Return Total Amount": 904.85 + } +] diff --git a/Module 5/Problem_26/approach.md b/Module 5/Problem_26/approach.md new file mode 100644 index 00000000..c638f19d --- /dev/null +++ b/Module 5/Problem_26/approach.md @@ -0,0 +1,7 @@ +### Number of operations: 2 +1. modify-overwrite-beta +2. remove + +### Approach +1. The modify-overwrite-beta operation is used along with the divide and doubleSum functions to calculate the product of the price and the quantity of the orders and then the tax is included in this to finally calculate the total return amount. +2. Finally, the remove operation is used to remove all the temporary variables that were made during the modify-overwrite-beta operation along with the pre-existing key-value pairs that were not required in the output json. \ No newline at end of file diff --git a/Module 5/Problem_27/Q27.json b/Module 5/Problem_27/Q27.json new file mode 100644 index 00000000..f74b2eaf --- /dev/null +++ b/Module 5/Problem_27/Q27.json @@ -0,0 +1,81 @@ +Input Json +[ + { + "returnId": "10051", + "returnQuantity": 2, + "returnPrice": 100, + "returnTax": 12.56, + "country": "USA" + }, + { + "returnId": "10052", + "returnQuantity": 25, + "returnPrice": 35, + "returnTax": 29.85, + "country": "CA" + }, + { + "returnId": "10053", + "returnQuantity": 5, + "returnPrice": 55, + "returnTax": 9.85, + "country": "" + } +] + +Json Spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "*": { + "Return Id": "@(1, returnId)", + "temp": "=divide(1,@(1,returnQuantity))", + "Return Amount": "=divide(@(1,returnPrice),@(1,temp))", + "Return Total Amount": "=doubleSum(@(1,Return Amount),@(1,returnTax))" + }, + "[0]": { + "Country": "United States of America" + }, + "[1]": { + "Country": "Canada" + }, + "[2]": { + "Country": "NA" + } + } + }, + { + "operation": "shift", + "spec": { + "*": { + "returnId": "[#2].Return Id", + "Return Amount": "[#2].Return Amount", + "Return Total Amount": "[#2].Return Total Amount", + "Country": "[#2].Country" + } + } + } +] + +Output Json + [ + { + "Return Id": "10051", + "Return Amount": 200.0, + "Return Total Amount": 212.56, + "Country": "United States of America" + }, + { + "Return Id": "10052", + "Return Amount": 875.0, + "Return Total Amount": 904.85, + "Country": "Canada" + }, + { + "Return Id": "10053", + "Return Amount": 275.0, + "Return Total Amount": 284.85, + "Country": "NA" + } +] \ No newline at end of file diff --git a/Module 5/Problem_27/approach.md b/Module 5/Problem_27/approach.md new file mode 100644 index 00000000..22458b33 --- /dev/null +++ b/Module 5/Problem_27/approach.md @@ -0,0 +1,7 @@ +### Number of operations: 2 +1. modify-overwrite-beta +2. shift + +### Approach +1. The modify-overwrite-beta operation is used along with the divide and doubleSum functions to calculate the product of the price and the quantity of the orders and then the tax is included in this to finally calculate the total return amount and then the country name is added to each element of the list seperately in order to change the abbreviations to full name of the countries. +2. Finally, the shift operation is used to transform the input json into the required structure to match with the output json. \ No newline at end of file diff --git a/Module 5/Problem_28/Q28.json b/Module 5/Problem_28/Q28.json new file mode 100644 index 00000000..ed7748fb --- /dev/null +++ b/Module 5/Problem_28/Q28.json @@ -0,0 +1,83 @@ +Input Json +[ + { + "returnId": "151", + "returnItemAdjustments": [ + { + "returnItemSeqId": "00001", + "amount": 28.64, + "returnAdjustmentTypeId": "RET_SALES_TAX_ADJ", + "description": "Return Sales Tax", + "createdDate": null, + "returnId": "151", + "returnAdjustmentId": "", + "comments": "Return Sales Tax", + "shipGroupSeqId": null + }, + { + "returnItemSeqId": "00001", + "amount": 58.64, + "returnAdjustmentTypeId": "RET_SALES_TAX_ADJ", + "description": "Return Sales Tax", + "createdDate": null, + "returnId": "151", + "returnAdjustmentId": "", + "comments": "Return Sales Tax", + "shipGroupSeqId": null + } + ] + }, + { + "returnId": "152", + "returnItemAdjustments": [ + { + "returnItemSeqId": "00002", + "amount": 38.64, + "returnAdjustmentTypeId": "RET_SALES_TAX_ADJ", + "description": "Return Sales Tax", + "createdDate": null, + "returnId": "152", + "returnAdjustmentId": "", + "comments": "Return Sales Tax", + "shipGroupSeqId": null + } + ] + } +] + +Json Spec +[ + { + "operation": "shift", + "spec": { + "*": { + "returnId": "[#2].returnId", + "returnItemAdjustments": { + "*": { + "amount": "[#4].returnTax" + } + } + } + } + }, + { + "operation": "modify-overwrite-beta", + "spec": { + "*": { + "returnTax": "=doubleSum(@(1,returnTax))" + } + } + } +] + +Output Json +[ + { + "returnId": "151", + "returnTax": 87.28 + }, + { + "returnId": "152", + "returnTax": 38.64 + } +] \ No newline at end of file diff --git a/Module 5/Problem_28/approach.md b/Module 5/Problem_28/approach.md new file mode 100644 index 00000000..b74606fd --- /dev/null +++ b/Module 5/Problem_28/approach.md @@ -0,0 +1,8 @@ +### Number of operations: 2 +1. shift +2. modify-overwrite-beta + + +### Approach +1. The shift operation is used to transform the structure of the given input json into the required output json by including only the required fields and a list is created with the amounts of each id as elements in the list . +2. In the second operation the doublSum function is used to calculate the sum of all the amounts in the returnTax list and it is overwritten with the modify-overwrite-beta operation. \ No newline at end of file diff --git a/Module 5/Problem_29/Q29.json b/Module 5/Problem_29/Q29.json new file mode 100644 index 00000000..8df64ea6 --- /dev/null +++ b/Module 5/Problem_29/Q29.json @@ -0,0 +1,35 @@ +Input Json +{ + "person": { + "name": "John Doe", + "age": 30, + "address": { + "city": "New York", + "state": "NY" + } + } +} + +Json Spec +[ + { + "operation": "shift", + "spec": { + "person": { + "name": "person_name", + "age": "person_age", + "address": { + "*": "person_address_&" + } + } + } + } +] + +Output Json +{ + "person_name": "John Doe", + "person_age": 30, + "person_address_city": "New York", + "person_address_state": "NY" +} \ No newline at end of file diff --git a/Module 5/Problem_29/approach.md b/Module 5/Problem_29/approach.md new file mode 100644 index 00000000..9bfe3cab --- /dev/null +++ b/Module 5/Problem_29/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. shift + +### Approach +1. The shift operation is used to transform the structure of the given input json into the required output json. \ No newline at end of file diff --git a/Module 5/Problem_3/Q3.json b/Module 5/Problem_3/Q3.json new file mode 100644 index 00000000..36881ada --- /dev/null +++ b/Module 5/Problem_3/Q3.json @@ -0,0 +1,30 @@ +Input JSON +{ + "name": "John", + "age": 35, + "city": "New York", + "phone": "+1-555-123-4567" +} + +Transformation Jolt +[ + { + "operation": "shift", + "spec": { + "name": "Name", + "age": "Age", + "city": "Contact.City", + "phone": "Contact.Phone" + } + } +] + +Output JSON +{ + "Name": "John", + "Age": 35, + "Contact": { + "City": "New York", + "Phone": "+1-555-123-4567" + } +} \ No newline at end of file diff --git a/Module 5/Problem_3/approach.md b/Module 5/Problem_3/approach.md new file mode 100644 index 00000000..129768c9 --- /dev/null +++ b/Module 5/Problem_3/approach.md @@ -0,0 +1,6 @@ +### Number of operations: 1 +1. Shift + +### Approach +1. The shift operation is used in order to replace name and age key with Name and Age and +shifted value of city and phone key inside a Contact map with keys City and Phone. \ No newline at end of file diff --git a/Module 5/Problem_30/Q30.json b/Module 5/Problem_30/Q30.json new file mode 100644 index 00000000..c8a672e0 --- /dev/null +++ b/Module 5/Problem_30/Q30.json @@ -0,0 +1,43 @@ +Input Json +{ + "person": { + "name": "John Doe", + "age": 30, + "address": { + "city": "New York", + "state": "NY" + } + }, + "employee": { + "name": "Jane Doe", + "salary": 50000, + "office": { + "city": "San Francisco", + "state": "CA" + } + } +} + +Json Spec +[ + { + "operation": "shift", + "spec": { + "person": { + "name": "&" + }, + "employee": { + "office": { + "*": "office-&" + } + } + } + } + ] + +Output Json +{ + "name": "John Doe", + "office-city": "San Francisco", + "office-state": "CA" +} \ No newline at end of file diff --git a/Module 5/Problem_30/approach.md b/Module 5/Problem_30/approach.md new file mode 100644 index 00000000..9bfe3cab --- /dev/null +++ b/Module 5/Problem_30/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. shift + +### Approach +1. The shift operation is used to transform the structure of the given input json into the required output json. \ No newline at end of file diff --git a/Module 5/Problem_31/Q31.json b/Module 5/Problem_31/Q31.json new file mode 100644 index 00000000..ef751bf0 --- /dev/null +++ b/Module 5/Problem_31/Q31.json @@ -0,0 +1,73 @@ +Input Json +{ + "items": [ + { + "id": "1", + "name": "Book", + "prices": [ + { + "currency": "USD", + "value": 10 + }, + { + "currency": "EUR", + "value": 8 + } + ] + }, + { + "id": "2", + "name": "Pen", + "prices": [ + { + "currency": "USD", + "value": 2 + }, + { + "currency": "EUR", + "value": 1.5 + } + ] + } + ] +} + +Json Spec +[ + { + "operation": "modify-default-beta", + "spec": { + "items": { + "*": { + "prices": { + "*": { + "temp": "=concat(@(3,id),'_',@(1,currency))" + } + } + } + } + } + }, + { + "operation": "shift", + "spec": { + "items": { + "*": { + "prices": { + "*": { + "@value": "@temp" + } + } + } + } + } + } +] + +Output Json +{ + "1_USD": 10, + "1_EUR": 8, + "2_USD": 2, + "2_EUR": 1.5 +} \ No newline at end of file diff --git a/Module 5/Problem_31/approach.md b/Module 5/Problem_31/approach.md new file mode 100644 index 00000000..d8b7080d --- /dev/null +++ b/Module 5/Problem_31/approach.md @@ -0,0 +1,8 @@ +### Number of operations: 2 +1. modify-overwrite-beta +2. shift + + +### Approach +1. The modify-overwrite-beta operation is used to concatenate the value of the key id with the value of the currency key. +2. The second operation i.e. the shift operation is used to change the structure of the json to match the output json and to include only the required details. \ No newline at end of file diff --git a/Module 5/Problem_32/Q32.json b/Module 5/Problem_32/Q32.json new file mode 100644 index 00000000..069c6da5 --- /dev/null +++ b/Module 5/Problem_32/Q32.json @@ -0,0 +1,51 @@ +Input JSON +{ + "data": [ + { + "x": "A", + "y": "1", + "value": 10 + }, + { + "x": "A", + "y": "2", + "value": 20 + }, + { + "x": "B", + "y": "1", + "value": 30 + }, + { + "x": "B", + "y": "2", + "value": 40 + } + ] +} + +JSON spec +[ + { + "operation": "shift", + "spec": { + "data": { + "*": { + "value": "@(1,x).@(1,y)" + } + } + } + } +] + +Output JSON +{ + "A" : { + "1" : 10, + "2" : 20 + }, + "B" : { + "1" : 30, + "2" : 40 + } +} \ No newline at end of file diff --git a/Module 5/Problem_32/approach.md b/Module 5/Problem_32/approach.md new file mode 100644 index 00000000..9bfe3cab --- /dev/null +++ b/Module 5/Problem_32/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. shift + +### Approach +1. The shift operation is used to transform the structure of the given input json into the required output json. \ No newline at end of file diff --git a/Module 5/Problem_33/Q33.json b/Module 5/Problem_33/Q33.json new file mode 100644 index 00000000..f56922dd --- /dev/null +++ b/Module 5/Problem_33/Q33.json @@ -0,0 +1,61 @@ +Input Json + +{ + "id": 1, + "name": "John", + "hobbies": [ + { + "name": "reading", + "level": "advanced" + }, + { + "name": "swimming", + "level": "beginner" + } + ] +} + + +Json Spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "hobbies": { + "*": { + "id": "@(3,id)", + "hobby_name": "@(1,name)", + "name": "@(3,name)", + "hobby_level": "@(1,level)" + } + } + } + } + , + { + "operation": "shift", + "spec": { + "hobbies": { + "*": { + "id": "[#2].&", + "name": "[#2].&", + "hobby_name": "[#2].&", + "hobby_level": "[#2].&" + } + } + } + } + ] + +// Output Json +[ { + "id" : 1, + "name" : "John", + "hobby_name" : "reading", + "hobby_level" : "advanced" +}, { + "id" : 1, + "name" : "John", + "hobby_name" : "swimming", + "hobby_level" : "beginner" +} ] diff --git a/Module 5/Problem_33/approach.md b/Module 5/Problem_33/approach.md new file mode 100644 index 00000000..c8e3b036 --- /dev/null +++ b/Module 5/Problem_33/approach.md @@ -0,0 +1,7 @@ +### Number of operations: 2 +1. modify-overwrite-beta +2. shift + +### Approach +1. The modify-overwrite-beta is used to create key-value pairs of id and name in the hobbies list. +2. The shift operation is used to transform the structure of the given input json into the required output json. \ No newline at end of file diff --git a/Module 5/Problem_34/Q34.json b/Module 5/Problem_34/Q34.json new file mode 100644 index 00000000..a9118f67 --- /dev/null +++ b/Module 5/Problem_34/Q34.json @@ -0,0 +1,38 @@ +Input JSON +{ + "name": "John", + "hobby_1": "reading", + "level_1": "advanced", + "hobby_2": "swimming", + "level_2": "beginner" +} + +JSON spec +[ + + { + "operation": "shift", + "spec": { + "name": "&", + "hobby_1": "hobbies[0].name", + "level_1": "hobbies[0].level", + "hobby_2": "hobbies[1].name", + "level_2": "hobbies[1].level" + } + } +] + +output json +{ + "name": "John", + "hobbies": [ + { + "name": "reading", + "level": "advanced" + }, + { + "name": "swimming", + "level": "beginner" + } + ] +} \ No newline at end of file diff --git a/Module 5/Problem_34/approach.md b/Module 5/Problem_34/approach.md new file mode 100644 index 00000000..a26ad901 --- /dev/null +++ b/Module 5/Problem_34/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. shift + +### Approach +1. The shift operation is used to change the structure to match the required structure of the output json. \ No newline at end of file diff --git a/Module 5/Problem_4/Q4.json b/Module 5/Problem_4/Q4.json new file mode 100644 index 00000000..9741c887 --- /dev/null +++ b/Module 5/Problem_4/Q4.json @@ -0,0 +1,38 @@ +Input JSON +{ + "name": "John", + "age": 35, + "hobbies": [ + "reading", + "movies", + "travel" + ] +} + + Jolt Spec +[ + { + "operation": "shift", + "spec": { + "name": "Name", + "age": "Age", + "hobbies": { + "*": "Hobbies[].Name" + } + } + } +] + + Output JSON +{ + "Name" : "John", + "Age" : 35, + "Hobbies" : [ { + "Name" : "reading" + }, { + "Name" : "movies" + }, { + "Name" : "travel" + } ] +} + \ No newline at end of file diff --git a/Module 5/Problem_4/approach.md b/Module 5/Problem_4/approach.md new file mode 100644 index 00000000..22a6b16b --- /dev/null +++ b/Module 5/Problem_4/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. Shift + +### Approach +1. The shift operation is used in order to change the keys and the values of hobbies list are placed in a list of maps Hobbies against the key Name. \ No newline at end of file diff --git a/Module 5/Problem_5/Q5.json b/Module 5/Problem_5/Q5.json new file mode 100644 index 00000000..62ee60fc --- /dev/null +++ b/Module 5/Problem_5/Q5.json @@ -0,0 +1,42 @@ +Input JSON + +{ + "firstName": "John", + "lastName": "Doe", + "email": "johndoe@example.com", + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + } +} + +Jolt spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "fullName": "=concat(@(1,firstName),' ',@(1,lastName))" + } + } + , { + "operation": "shift", + "spec": { + "fullName": "&", + "email": "&", + "address": { + "city": "&", + "zip": "&" + } + } + } +] + +Output JSON +{ + "fullName" : "John Doe", + "email" : "johndoe@example.com", + "city" : "Anytown", + "zip" : "12345" +} \ No newline at end of file diff --git a/Module 5/Problem_5/approach.md b/Module 5/Problem_5/approach.md new file mode 100644 index 00000000..3f7286fc --- /dev/null +++ b/Module 5/Problem_5/approach.md @@ -0,0 +1,6 @@ +### Number of operations: 2 +1. modify-overwrite-beta +2. shift +### Approach +1. The modify-overwrite-beta is used in order to concatenate the firstName and the lastName and it's key is named as fullName. +2. The shift operation is then used in order to get the desired output in that particular order. \ No newline at end of file diff --git a/Module 5/Problem_6/Q6.json b/Module 5/Problem_6/Q6.json new file mode 100644 index 00000000..035e96ef --- /dev/null +++ b/Module 5/Problem_6/Q6.json @@ -0,0 +1,88 @@ +Input JSON +{ + "users": [ + { + "name": "John Doe", + "age": 35, + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + }, + "hobbies": [ + { + "name": "reading", + "type": "indoor" + }, + { + "name": "hiking", + "type": "outdoor" + } + ] + }, + { + "name": "Jane Doe", + "age": 30, + "address": { + "street": "456 First St", + "city": "Othertown", + "state": "NY", + "zip": "67890" + }, + "hobbies": [ + { + "name": "swimming", + "type": "outdoor" + }, + { + "name": "painting", + "type": "indoor" + } + ] + } + ] +} + +Jolt Spec +[ + { + "operation": "modify-overwrite-beta", + "spec": { + "users": { + "*": { + "Address": "=concat(@(1,address.street),', ',@(1,address.city),', ',@(1,address.state),', ',@(1,address.zip))" + } + } + } + }, + { + "operation": "shift", + "spec": { + "users": { + "*": { + "name": "[#2].Name", + "Address": "[#2].Address", + "hobbies": { + "*": { + "name": "[#4].Hobbies" + } + } + } + } + } + } +] + +Output JSON +[ { + "Name" : "John Doe", + "Address" : "123 Main St, Anytown, CA, 12345", + "Hobbies" : [ "reading", "hiking" ] +}, +{ + "Name" : "Jane Doe", + "Address" : "456 First St, Othertown, NY, 67890", + "Hobbies" : [ "swimming", "painting" ] +} +] diff --git a/Module 5/Problem_6/approach.md b/Module 5/Problem_6/approach.md new file mode 100644 index 00000000..8337b18e --- /dev/null +++ b/Module 5/Problem_6/approach.md @@ -0,0 +1,7 @@ +### Number of operations: 2 +1. modify-overwrite-beta +2. shift + +### Approach +1. The modify-overwrite-beta operation is used to concatenate the address fields and store it as a value against the key Address. +2. The shift operation is used in order to change the required keys and to store the name of hobbies in a list name Hobbies. \ No newline at end of file diff --git a/Module 5/Problem_7/Q7.json b/Module 5/Problem_7/Q7.json new file mode 100644 index 00000000..84437aab --- /dev/null +++ b/Module 5/Problem_7/Q7.json @@ -0,0 +1,55 @@ +Input JSON +{ + "students": [ + { + "name": "John Doe", + "age": 23, + "email": "john.doe@example.com" + }, + { + "name": "Jane Smith", + "age": 25, + "email": "jane.smith@example.com" + } + ] + } + +Jolt Spec + [ + { + "operation": "modify-overwrite-beta", + "spec": { + "students": { + "*": { + "Email": "=split('@',@(1,email))" + //"Domain": "@(1,Email.[1])" + } + } + } + }, + { + "operation": "shift", + "spec": { + "students": { + "*": { + "name": "[#2].Name", + "age": "[#2].Age", + "Email": { + "@(1,Email.[1])": "[#3].Domain" + } + } + } + } + } + ] + Output JSON + [ { + "Name" : "name", + "Age" : "age", + "Domain" : "example.com" + }, { + "Name" : "name", + "Age" : "age", + "Domain" : "example.com" + } + ] \ No newline at end of file diff --git a/Module 5/Problem_7/approach.json b/Module 5/Problem_7/approach.json new file mode 100644 index 00000000..e678d871 --- /dev/null +++ b/Module 5/Problem_7/approach.json @@ -0,0 +1,7 @@ +### Number of operations: 2 +1. modify-overwrite-beta +2. shift + +### Approach +1. The modify-overwrite-beta operation is used to split the email id in the input json based on the seperator '@'. +2. The shift operation is used in order to change the required keys and to use the second element of the list Email to be used as the value of the key Domain. \ No newline at end of file diff --git a/Module 5/Problem_8/Q8.json b/Module 5/Problem_8/Q8.json new file mode 100644 index 00000000..654e872c --- /dev/null +++ b/Module 5/Problem_8/Q8.json @@ -0,0 +1,74 @@ +Input : +{ + "employees": [ + { + "name": "John Doe", + "salary": 50000, + "department": "Sales" + }, + { + "name": "Jane Smith", + "salary": 60000 + }, + { + "name": "Bob Johnson", + "department": "IT" + } + ] +} + +Transformation: +[ + { + "operation": "modify-default-beta", + "spec": { + "employees": { + "[0]": { + "bonus": 1000, + "totalBonus": 1000 + }, + "[1]": { + "bonus": 1500, + "totalBonus": 1500 + }, + "[2]": { + "salary": 45000, + "bonus": 900, + "totalBonus": 900 + } + } + } + }, + { + "operation": "shift", + "spec": { + "employees": { + "*": { + "*": "employees.[#2].&", + "totalBonus": "&[]" + } + } + } + }, + { + "operation": "modify-overwrite-beta", + "spec": { + "totalBonus": "=intSum(@(1,totalBonus))" + } + }] + +Output: +{ + "employees" : [ { + "name" : [ "John Doe", "Jane Smith", "Bob Johnson" ] + }, { + "salary" : [ 50000, 60000 ], + "department" : "IT" + }, { + "department" : "Sales", + "bonus" : [ 1500, 900 ] + }, { + "bonus" : 1000 + } ], + "totalBonus" : 3400 +} diff --git a/Module 5/Problem_8/approach.md b/Module 5/Problem_8/approach.md new file mode 100644 index 00000000..0c457b3a --- /dev/null +++ b/Module 5/Problem_8/approach.md @@ -0,0 +1,8 @@ +### Number of operations: 3 +1. modify-overwrite-beta +2. shift + +### Approach +1. The first modify-overwrite-beta operation is used to add the bonus to each employee object. +2. The shift operation is used in order to select only the required fields and to create a list with all the bonuses of each employee object. +3. Finally, the third operation- modify-overwrite-beta is used along with the intSum function to get the sum of all the bonuses in the totalBonus list. \ No newline at end of file diff --git a/Module 5/Problem_9/Q9.json b/Module 5/Problem_9/Q9.json new file mode 100644 index 00000000..3ab5fc4c --- /dev/null +++ b/Module 5/Problem_9/Q9.json @@ -0,0 +1,34 @@ +Input JSON +{ + "name": "John", + "age": 30, + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA", + "zip": "12345" + } +} + +Jolt Spec +[ + { + "operation": "remove", + "spec": { + "address": { + "state": "" + } + } + } +] + +Output JSON +{ + "name" : "John", + "age" : 30, + "address" : { + "street" : "123 Main St", + "city" : "Anytown", + "zip" : "12345" + } +} \ No newline at end of file diff --git a/Module 5/Problem_9/approach.md b/Module 5/Problem_9/approach.md new file mode 100644 index 00000000..d3f53b33 --- /dev/null +++ b/Module 5/Problem_9/approach.md @@ -0,0 +1,5 @@ +### Number of operations: 1 +1. remove + +### Approach +1. The remove operation is used to remove the state key in the given input json. \ No newline at end of file From 6d0998c494523abf87ee2e7189a86e914d4371bd Mon Sep 17 00:00:00 2001 From: Prakhar Yadav Date: Fri, 2 Jun 2023 12:21:07 +0530 Subject: [PATCH 5/5] Made some minor modifications in question 1,7,8,14,and 18 --- Module 5/Problem_1/Q1.json | 24 ++++++----- Module 5/Problem_14/Q14.json | 78 ++++++++++++++++++------------------ Module 5/Problem_18/Q18.json | 21 +++++----- Module 5/Problem_7/Q7.json | 19 +++++---- Module 5/Problem_8/Q8.json | 22 ++++++---- 5 files changed, 88 insertions(+), 76 deletions(-) diff --git a/Module 5/Problem_1/Q1.json b/Module 5/Problem_1/Q1.json index 312aac28..73f833e3 100644 --- a/Module 5/Problem_1/Q1.json +++ b/Module 5/Problem_1/Q1.json @@ -80,6 +80,11 @@ json Spec: "spec": { "orders": { "*": { + "items": { + "*": { + "price": "=toDouble(@(1,price))" + } + }, "itemTemp": { "*": { "inverseValue": "=divide(1,@(1,price))", @@ -137,6 +142,7 @@ json Spec: } ] + Output: { "orders" : [ { @@ -144,21 +150,20 @@ Output: "orderDate" : "2022-02-20T12:34:56Z", "customer" : { "customerId" : 1, - "firstName" : "John", - "lastName" : "Doe", "email" : "johndoe@example.com", - "address" : "123 Main St Anytown CA 12345" + "address" : "123 Main St Anytown CA 12345", + "fullname" : "John Doe" }, "items" : [ { "itemId" : 1, "name" : "Product A", "quantity" : 2, - "price" : 10 + "price" : 10.0 }, { "itemId" : 2, "name" : "Product B", "quantity" : 1, - "price" : 20 + "price" : 20.0 } ], "total" : 40.0 }, { @@ -166,17 +171,16 @@ Output: "orderDate" : "2022-02-21T09:12:34Z", "customer" : { "customerId" : 2, - "firstName" : "Jane", - "lastName" : "Smith", "email" : "janesmith@example.com", - "address" : "456 Oak St Somewhere NY 67890" + "address" : "456 Oak St Somewhere NY 67890", + "fullname" : "Jane Smith" }, "items" : [ { "itemId" : 3, "name" : "Product C", "quantity" : 3, - "price" : 15 + "price" : 15.0 } ], "total" : 45.0 } ] -} \ No newline at end of file +} diff --git a/Module 5/Problem_14/Q14.json b/Module 5/Problem_14/Q14.json index f1e34df1..8344ac34 100644 --- a/Module 5/Problem_14/Q14.json +++ b/Module 5/Problem_14/Q14.json @@ -37,47 +37,47 @@ Input Json Json Spec [ { - "operation": "shift", - "spec": { - "employees": { - "*": { - "id": "employees.[#2].&", - "name": "employees.[#2].&", - "phone": { - "*": { - "@number": "employees.[#4].@type" - } - } - } + "operation": "shift", + "spec": { + "employees": { + "*": { + "id": "employees.[#2].&", + "name": "employees.[#2].&", + "phone": { + "*": { + "@number": "employees.[#4].@type" + } } + } } - }, + } + }, { - "operation": "shift", - "spec": { - "employees": { - "*": { - "*": "[#2].&", - "home": "[#2].homePhone", - "work": "[#2].workPhone" - } - } + "operation": "shift", + "spec": { + "employees": { + "*": { + "*": "employees.[#2].&", + "home": "employees.[#2].homePhone", + "work": "employees.[#2].workPhone" + } } - } -] - + } + } + ] + Ouput Json -[ - { - "id": "001", - "name": "John", - "homePhone": "555-555-1234", - "workPhone": "555-555-5678" - }, - { - "id": "002", - "name": "Jane", - "homePhone": "555-555-4567", - "workPhone": "555-555-8901" - } -] \ No newline at end of file +{ + "employees" : [ { + "id" : "001", + "name" : "John", + "homePhone" : "555-555-1234", + "workPhone" : "555-555-5678" + }, { + "id" : "002", + "name" : "Jane", + "homePhone" : "555-555-4567", + "workPhone" : "555-555-8901" + } ] + } + \ No newline at end of file diff --git a/Module 5/Problem_18/Q18.json b/Module 5/Problem_18/Q18.json index dd2cc220..e9f64f3d 100644 --- a/Module 5/Problem_18/Q18.json +++ b/Module 5/Problem_18/Q18.json @@ -27,7 +27,7 @@ Jolt Spec "employees": { "*": { "temp": "=divideAndRound(0,@(1,salary),10)", - "salary": "=doubleSum(@(1,salary),@(1,temp))" + "salary": "=intSum(@(1,salary),@(1,temp))" } } } @@ -35,27 +35,28 @@ Jolt Spec { "operation": "remove", "spec": { - "temp": "" + "employees": { + "*": { + "temp": "" + } + } } } -] +] Output JSON { "employees" : [ { "name" : "John", "age" : 30, - "salary" : 5500.0, - "temp" : 500.0 + "salary" : 5500 }, { "name" : "Jane", "age" : 35, - "salary" : 6600.0, - "temp" : 600.0 + "salary" : 6600 }, { "name" : "Bob", "age" : 40, - "salary" : 7700.0, - "temp" : 700.0 + "salary" : 7700 } ] -} \ No newline at end of file +} diff --git a/Module 5/Problem_7/Q7.json b/Module 5/Problem_7/Q7.json index 84437aab..4d2c3d02 100644 --- a/Module 5/Problem_7/Q7.json +++ b/Module 5/Problem_7/Q7.json @@ -43,13 +43,12 @@ Jolt Spec } ] Output JSON - [ { - "Name" : "name", - "Age" : "age", - "Domain" : "example.com" - }, { - "Name" : "name", - "Age" : "age", - "Domain" : "example.com" - } - ] \ No newline at end of file + [ { + "Name" : "John Doe", + "Age" : 23, + "Domain" : "example.com" +}, { + "Name" : "Jane Smith", + "Age" : 25, + "Domain" : "example.com" +} ] diff --git a/Module 5/Problem_8/Q8.json b/Module 5/Problem_8/Q8.json index 654e872c..a7fb1db1 100644 --- a/Module 5/Problem_8/Q8.json +++ b/Module 5/Problem_8/Q8.json @@ -28,6 +28,7 @@ Transformation: "totalBonus": 1000 }, "[1]": { + "department": "Marketing", "bonus": 1500, "totalBonus": 1500 }, @@ -57,18 +58,25 @@ Transformation: } }] + Output: { "employees" : [ { - "name" : [ "John Doe", "Jane Smith", "Bob Johnson" ] - }, { - "salary" : [ 50000, 60000 ], - "department" : "IT" - }, { + "name" : "John Doe", + "salary" : 50000, "department" : "Sales", - "bonus" : [ 1500, 900 ] - }, { "bonus" : 1000 + }, { + "name" : "Jane Smith", + "salary" : 60000, + "department" : "Marketing", + "bonus" : 1500 + }, { + "name" : "Bob Johnson", + "department" : "IT", + "salary" : 45000, + "bonus" : 900 } ], "totalBonus" : 3400 } +