Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d8f1662
Transformation Spec for Question 1
DhruvSingh861 Apr 23, 2023
e8295ee
Transformation Spec for Question 2
DhruvSingh861 Apr 23, 2023
6799b64
Transformation Spec for Question 3
DhruvSingh861 Apr 23, 2023
573052a
Transformation Spec for Question 4
DhruvSingh861 Apr 23, 2023
ae5552d
Transformation Spec for Question 5
DhruvSingh861 Apr 23, 2023
5d2def5
Transformation Spec for Question 6
DhruvSingh861 Apr 23, 2023
2a8c315
Transformation Spec for Question 7
DhruvSingh861 Apr 23, 2023
be525f3
Transformation Spec for Question 8
DhruvSingh861 Apr 23, 2023
a5f4f54
Transformation Spec for Question 9
DhruvSingh861 Apr 23, 2023
657e496
Transformation Spec for Question 10
DhruvSingh861 Apr 23, 2023
00072ff
Transformation Spec for Question 11
DhruvSingh861 Apr 23, 2023
d0a341a
Transformation Spec for Question 12
DhruvSingh861 Apr 23, 2023
5b9376b
Transformation Spec for Question 13
DhruvSingh861 Apr 23, 2023
84b1b34
Transformation Spec for Question 14
DhruvSingh861 Apr 23, 2023
d9a654c
Transformation Spec for Question 17
DhruvSingh861 Apr 23, 2023
da6ac1a
Transformation Spec for Question 18
DhruvSingh861 Apr 23, 2023
ce62bf9
Transformation Spec for Question 19
DhruvSingh861 Apr 23, 2023
6a39322
Transformation Spec for Question 20
DhruvSingh861 Apr 23, 2023
77acbf6
Transformation Spec for Question 21
DhruvSingh861 Apr 23, 2023
6eda4c9
Transformation Spec for Question 22
DhruvSingh861 Apr 23, 2023
b248328
Transformation Spec for Question 23
DhruvSingh861 Apr 23, 2023
7c205e0
Transformation Spec for Question 24
DhruvSingh861 Apr 23, 2023
ea99300
Transformation Spec for Question 25
DhruvSingh861 Apr 23, 2023
904b958
Transformation Spec for Question 26
DhruvSingh861 Apr 23, 2023
f11fb29
Transformation Spec for Question 27
DhruvSingh861 Apr 23, 2023
952fb3b
Transformation Spec for Question 28
DhruvSingh861 Apr 23, 2023
0c917a8
Transformation Spec for Question 29
DhruvSingh861 Apr 23, 2023
b672c56
Transformation Spec for Question 30
DhruvSingh861 Apr 23, 2023
84f590d
Transformation Spec for Question 31
DhruvSingh861 Apr 23, 2023
12ad8b5
Transformation Spec for Question 32
DhruvSingh861 Apr 23, 2023
5466ecd
Transformation Spec for Question 33
DhruvSingh861 Apr 23, 2023
3de3e2c
Transformation Spec for Question 34
DhruvSingh861 Apr 23, 2023
e78c26c
added descriptions for all problems.
DhruvSingh861 May 4, 2023
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
5 changes: 5 additions & 0 deletions question 1/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
In first modify-overwrite-beta operation we are iterating to very map of items list and storing quantity * price as singleTotalItem
In second operation I am puting items into items and temp Items so, that we can perform operations on tempItems and our original items list remains as it is.
In third operation we are storing totalSingleItem of every elemt of itemsTemp into priceList.
In third operation we are doing the doubleSum of elemts of priceList and also doubling the price value.
finally removing unnecessary data which we dont want in out output JSON using remove operation.
58 changes: 58 additions & 0 deletions question 1/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"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
}
]
}
]
}
48 changes: 48 additions & 0 deletions question 1/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"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
}
]
}
90 changes: 90 additions & 0 deletions question 1/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
[
{
"operation": "modify-overwrite-beta",
"spec": {
"orders": {
"*": {
"items": {
"*": {
"temp": "=divide(1,@(1,quantity))",
"totalSingleItem": "=divide(@(1,price),@(1,temp))"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"orders": {
"*": {
"*": "orders[&1].&",
"items": ["orders[&1].itemsTemp", "orders[&1].items"]
}
}
}
}

,
{
"operation": "shift",
"spec": {
"orders": {
"*": {
"*": "orders[&1].&",
"itemsTemp": {
"*": {
"@(0,totalSingleItem)": "orders[&3].priceList[#2]"
}
}
}
}
}
}
,

{
"operation": "modify-overwrite-beta",
"spec": {
"orders": {
"*": {
"total": "=doubleSum(@(1,priceList))",
"customer": {
"fullName": "=concat(@(1,firstName),' ',@(1,lastName))",
"Address": "=concat(@(1,address.street),', ',@(1,address.city),', ',@(1,address.state),', ',@(1,address.zip))"
},
"items": {
"*": {
"price": ["=toDouble", null]
}
}
}
}
}
}
,
{
"operation": "remove",
"spec": {
"orders": {
"*": {
"customer": {
"firstName": "",
"lastName": "",
"address": ""
},
"items": {
"*": {
"temp": "",
"totalSingleItem": ""
}
},
"priceList": ""
}
}
}
}


]
2 changes: 2 additions & 0 deletions question 10/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
we want to split name into firstName and lastName, as name are seperated by ' ', we have used "* *" where firstName contains all character before 1st * and lastName will contains all charcater after 2nd *.
then in second operation, I have calculated the size of phone_numbers list.
20 changes: 20 additions & 0 deletions question 10/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"
}
]
}
19 changes: 19 additions & 0 deletions question 10/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"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
}
20 changes: 20 additions & 0 deletions question 10/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"operation": "shift",
"spec": {
"*": "&",
"name": {
"* *": {
"$(0,1)": "first_name",
"$(0,2)": "last_name"
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"phone_number_count": "=size(@(1,phone_numbers))"
}
}
]
1 change: 1 addition & 0 deletions question 11/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
we have used shift to change the name and value key foe every element of items list.
12 changes: 12 additions & 0 deletions question 11/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 question 11/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 question 11/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"operation": "shift",
"spec": {
"items": {
"*": {
"name": "items[#2].itemName",
"value": "items[#2].itemValue"
}
}
}
}
]
3 changes: 3 additions & 0 deletions question 12/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
firstly I have used shift to put all data from employee map to map outside employee.
then I have concatinated name and address.
then I have removed firstName and LastName.
22 changes: 22 additions & 0 deletions question 12/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"
}
]
}
}
14 changes: 14 additions & 0 deletions question 12/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "John Doe",
"address": "123 Main St, Anytown, CA 12345",
"phoneNumbers": [
{
"type": "home",
"number": "555-555-1234"
},
{
"type": "work",
"number": "555-555-5678"
}
]
}
26 changes: 26 additions & 0 deletions question 12/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"operation": "shift",
"spec": {
"employee": {
"*": "&"
}
}
}
,
{
"operation": "modify-overwrite-beta",
"spec": {
"name": "=concat(@(1,firstName),' ',@(1,lastName))",
"address": "=concat(@(1,address.street),', ',@(1,address.city),', ',@(1,address.state),', ',@(1,address.zip))"
}
}
,
{
"operation": "remove",
"spec": {
"firstName": "",
"lastName": ""
}
}
]
2 changes: 2 additions & 0 deletions question 13/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
firstly we want or convert employee from list to map with key as id.
we need to change the key of index od employye list that's why I have used "@" on RHS to get value of above * (i.e keys are 0, 1, 2, 3.... and therir values are maps whgich we are fetching) and store it into value of id.
Loading