Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions JOLT/problem1/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### Number of operation : 4
1. modify-overwrite-beta
2. shift
3. modify-overwrite-beta
4. remove

### Explanation
1. This operation modifies the "orders" structure by adding or updating certain fields. It adds the "fullName" field by concatenating the "firstName" and "lastName" fields of the "customer". It also adds the "address" field by concatenating the "street", "city", "state", and "zip" fields of the "address". It calculates the "totals" price of each item.

2. This operation restructures the "orders" data by moving certain fields to a new location. It creates a new list called "orders" and assigns each orders map to an index in that list. It also moves the "items" list to the corresponding order map and also move the "totals" field to the order map.

3. This operation modifies the "orders" structure again by calculating the sum of the "total" field for each order.

4. This operation removes certain fields from the "orders" structure. It removes the "firstName" and "lastName" fields from the "customer" object and removes the "totals" and "totalquan" fields from each item.
59 changes: 59 additions & 0 deletions JOLT/problem1/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"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
}
]
}
]
}

40 changes: 40 additions & 0 deletions JOLT/problem1/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"orders" : [ {
"orderId" : 1,
"orderDate" : "2022-02-20T12:34:56Z",
"customer" : {
"customerId" : 1,
"email" : "johndoe@example.com",
"address" : "123 Main St, Anytown, CA 12345",
"fullName" : "John Doe"
},
"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,
"email" : "janesmith@example.com",
"address" : "456 Oak St, Somewhere, NY 67890",
"fullName" : "Jane Smith"
},
"items" : [ {
"itemId" : 3,
"name" : "Product C",
"quantity" : 3,
"price" : 15.0
} ],
"total" : 45.0
} ]
}
67 changes: 67 additions & 0 deletions JOLT/problem1/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[
{
"operation": "modify-overwrite-beta",
"spec": {
"orders": {
"*": {
"customer": {
"fullName": "=concat(@(1,firstName),' ',@(1,lastName))",
"address?": "=concat(@(1,address.street),', ',@(1,address.city),', ', @(1,address.state),' ', @(1,address.zip))"
},
"items": {
"*": {
"totalquan": "=divide(1,@(1,quantity))",
"price?": "=toDouble",
"totals": "=divide(@(1,price),@(1,totalquan))"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"orders": {
"*": {
"*": "orders[&1].&",
"items": {
"*": {
"@": "orders[&3].items[]",
"totals": "orders[&3].total"
}
}
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"orders": {
"*": {
"total": "=doubleSum(@(1,total))"
}
}
}
},
{
"operation": "remove",
"spec": {
"orders": {
"*": {
"customer": {
"firstName": "",
"lastName": ""
},
"items": {
"*": {
"totals": " ",
"totalquan": ""
}
}
}
}
}
}
]
8 changes: 8 additions & 0 deletions JOLT/problem10/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Number of operation : 2
1. modify-overwrite-beta
2. shift

### Explanation
1. This operation modifies the structure by splitting the value of the "name" field into an list using the "split" function. It assigns the first element of the resulting list to the "first_name" field and the last element to the "last_name" field. It also calculates the size of the "phone_numbers" list and assigns it to the "phone_numbers_count" field.

2. This operation restructures the given structure by assigning specific fields to new field names.
20 changes: 20 additions & 0 deletions JOLT/problem10/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"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"
}
]
}
18 changes: 18 additions & 0 deletions JOLT/problem10/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"first_name" : "John",
"last_name" : "Smith",
"address" : {
"street" : "123 Main St",
"city" : "Anytown",
"state" : "CA",
"zip" : "12345"
},
"phone_numbers" : [ {
"type" : "home",
"number" : "555-1234"
}, {
"type" : "work",
"number" : "555-5678"
} ],
"phone_numbers_count" : 2
}
20 changes: 20 additions & 0 deletions JOLT/problem10/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"operation": "modify-overwrite-beta",
"spec": {
"name": "=split(' ',@(1,name))",
"first_name": "=firstElement(@(1,name))",
"last_name": "=lastElement(@(1,name))",
"phone_numbers_count": "=size(@(1,phone_numbers))"
}
}, {
"operation": "shift",
"spec": {
"first_name": ".&",
"last_name": ".&",
"address": ".&",
"phone_numbers": ".&",
"phone_numbers_count": ".&"
}
}
]
5 changes: 5 additions & 0 deletions JOLT/problem11/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Number of operations : 1
1. shift

### Explanation
1. This operation restructures the given structure by extracting specific fieldsand assigning them to new field names. It creates a new list called "items" and assigns each item map to an index in that list. It moves the value of the "name" field to "itemName" and the value of the "value" field to "itemValue" within each item.
12 changes: 12 additions & 0 deletions JOLT/problem11/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"items": [
{
"name": "item1",
"value": 10
},
{
"name": "item2",
"value": 20
}
]
}
9 changes: 9 additions & 0 deletions JOLT/problem11/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"items" : [ {
"itemName" : "item1",
"itemValue" : 10
}, {
"itemName" : "item2",
"itemValue" : 20
} ]
}
13 changes: 13 additions & 0 deletions JOLT/problem11/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"operation": "shift",
"spec": {
"items": {
"*": {
"name": "items[&1].itemName",
"value": "items[&1].itemValue"
}
}
}
}
]
8 changes: 8 additions & 0 deletions JOLT/problem12/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Number of operation : 2
1. modify-overwrite-beta
2. shift

### Explanation
1. This operation modifies the given structure by concatenating the values of the "firstName" and "lastName" fields within the "employee" map and assigning the result to the "name" field. It also concatenates the values of the "street", "city", "state", and "zip" fields within the "address" map and assigns the result to the "address" field.

2. This operation restructures the given structure by extracting specific fields and assigning them to new field names. It moves the value of the "name" field within the "employee" map to "employee.name", the value of the "address" field to "employee.address", and the value of the "phones" field to "employee.phoneNumbers".
22 changes: 22 additions & 0 deletions JOLT/problem12/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"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"
}
]
}
}
13 changes: 13 additions & 0 deletions JOLT/problem12/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"employee" : {
"name" : "John Doe",
"address" : "123 Main St, Anytown, CA 12345",
"phoneNumbers" : [ {
"type" : "home",
"number" : "555-555-1234"
}, {
"type" : "work",
"number" : "555-555-5678"
} ]
}
}
22 changes: 22 additions & 0 deletions JOLT/problem12/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"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": "employee.name",
"address": "employee.address",
"phones": "employee.phoneNumbers"
}
}
}
]
8 changes: 8 additions & 0 deletions JOLT/problem13/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Number of operation : 2
1. shift
2. remove

### Explanation
1. This operation restructures the given structure by extracting specific fields and assigning them to new field names. It creates a new name called "employees" and assigns each employee map to an index based on its "id".

2. This operation modifies the given structure by removing the "id" field within each employee map.
Loading