Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3b55c86
create spec for Q 1
sanskar345 May 12, 2023
c29c4d7
create spec for Q 2
sanskar345 May 12, 2023
c8ada60
create spec for Q 3
sanskar345 May 12, 2023
2ef76b4
create spec for Q 4
sanskar345 May 12, 2023
be2efaa
create spec for Q 5
sanskar345 May 12, 2023
0a0583f
create spec for Q 6
sanskar345 May 12, 2023
7efd1f3
create spec for Q 7
sanskar345 May 12, 2023
5d1695c
create spec for Q 9
sanskar345 May 12, 2023
5bcbbae
create spec for Q 10
sanskar345 May 12, 2023
569c45a
create spec for Q 11
sanskar345 May 12, 2023
8545e32
create spec for Q 12
sanskar345 May 12, 2023
3970824
create spec for Q 13
sanskar345 May 12, 2023
8a8db8e
create spec for Q 14
sanskar345 May 12, 2023
30dac1b
create spec for Q 16, 17
sanskar345 May 17, 2023
cc94761
create spec for Q 18
sanskar345 May 17, 2023
19b8e5a
create spec for Q 19
sanskar345 May 17, 2023
5f11df0
create spec for Q 19, 21, 22
sanskar345 May 17, 2023
6bec582
create spec for Q 23
sanskar345 May 17, 2023
feb221e
create spec for Q 23
sanskar345 May 17, 2023
0ffc30c
create spec for Q 24, 25
sanskar345 May 17, 2023
fc64d98
create spec for Q 26
sanskar345 May 17, 2023
b74d136
create spec for Q 27
sanskar345 May 17, 2023
7085e1d
create spec for Q 28
sanskar345 May 17, 2023
96c8802
create spec for Q 29
sanskar345 May 17, 2023
0c7f9a3
create spec for Q 30
sanskar345 May 17, 2023
0ac53c6
create spec for Q 31
sanskar345 May 17, 2023
f8c1820
create spec for Q 32
sanskar345 May 18, 2023
13def1e
create spec for Q 33
sanskar345 May 18, 2023
292d203
create spec for Q 34
sanskar345 May 18, 2023
4a04d29
create spec for Q 15
sanskar345 May 18, 2023
86597c0
create spec for Q 20
sanskar345 May 18, 2023
01cd8a4
create explanation file for the remaining questions
sanskar345 May 18, 2023
4e4aa07
changes in Q8
sanskar345 May 26, 2023
0efef38
changes in Q13
sanskar345 May 26, 2023
cea7475
changes in Q15
sanskar345 May 26, 2023
dce04ad
some correction
sanskar345 May 29, 2023
781869f
changes in Q 1
sanskar345 Jun 2, 2023
7057e77
optimized Q 33
sanskar345 Jun 2, 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
15 changes: 15 additions & 0 deletions Question-1/explanation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Number of Operation - 4

1 - modify-overwrite-beta
2 - shift
3 - modify-overwrite-beta
4 - remove

In the first operation concating the firstName and lastName and making field fullname and also concating the child of
address in address key changing its value using concat function. In this also multiplying the quantity with item total.

In the second operation structuring the things and adding total outside the items.

In the third operation summing up the total array.

In the fourth operation removing firstname, lastname and temp creted temp created in first 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
}
]
}
]
}
49 changes: 49 additions & 0 deletions Question-1/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"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
}
]
}

66 changes: 66 additions & 0 deletions Question-1/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[
{
"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": {
"*": {
"temp": "=divide(1,@(1,price))",
"total": "=divide(@(1,quantity),@(1,temp))"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"orders": {
"*": {
"*": "orders[#2].&",
"items": {
"*": {
"*": "orders.[&3].items[&1].&",
"total": "orders[#2].&"
}
}
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"orders": {
"*": {
"total": "=doubleSum"
}
}
}
},
{
"operation": "remove",
"spec": {
"orders": {
"*": {
"customer": {
"firstName": "",
"lastName": ""
},
"items": {
"*": {
"temp": ""
}
}
}
}
}
}

]
11 changes: 11 additions & 0 deletions Question-10/explanation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Number of Operation - 3

1 - modify-overwrite-beta
2 - modify-overwrite-beta
3 - shift

In the first operation spliting the name with " " so that we can get first and last name and also storing the count of phne number size with a new field

In the second operation just adding two new fields firstname and lastName with the first and last element of name array with function firstElement and lastElement.

In third operation removing the name field which is no longer needed.
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"
}
]
}
22 changes: 22 additions & 0 deletions Question-10/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"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
}
23 changes: 23 additions & 0 deletions Question-10/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"operation": "modify-overwrite-beta",
"spec": {
"name": "=split(' ', @(1,name))",
"phone_number_count": "=size(@(1, phone_numbers))"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"first_name": "=firstElement(@(1,name))",
"last_name": "=lastElement(@(1,name))"
}
},
{
"operation": "remove",
"spec": {
"name": " "
}
}
]

5 changes: 5 additions & 0 deletions Question-11/explanation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Number of Operation - 1

1 - shift

In this operation chnageing the name to iteName and value to Item value using shift operation.
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
}
]
}
12 changes: 12 additions & 0 deletions Question-11/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"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[&1].itemName",
"value": "items[&1].itemValue"
}
}
}
}
]
8 changes: 8 additions & 0 deletions Question-12/explanation.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

In the firt operation concating the name with firt name and last name by using concat function.

In the second operation just structuring things as per the given output.
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"
}
]
}
}
15 changes: 15 additions & 0 deletions Question-12/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "John Doe",
"address": "123 Main St, Anytown, CA 12345",
"phoneNumbers": [
{
"type": "home",
"number": "555-555-1234"
},
{
"type": "work",
"number": "555-555-5678"
}
]
}

Loading