Skip to content

Commit de3d474

Browse files
committed
Commands for jq file
1 parent d58c8dd commit de3d474

File tree

13 files changed

+67
-1
lines changed

13 files changed

+67
-1
lines changed

jq/scores.json

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,55 @@
1-
[{"name": "Ahmed", "city": "London", "scores": [1, 10, 4]}, {"name": "Basia", "city": "London", "scores": [22, 9, 6]}, {"name": "Mehmet", "city": "Birmingham", "scores": [3, 12, 17]}, {"name": "Leila", "city": "London", "scores": [1]}, {"name": "Piotr", "city": "Glasgow", "scores": [15, 2, 25, 11, 8]}, {"name": "Chandra", "city": "Birmingham", "scores": [12, 6]}]
1+
[
2+
{
3+
"name": "Ahmed",
4+
"city": "London",
5+
"scores": [
6+
1,
7+
10,
8+
4
9+
]
10+
},
11+
{
12+
"name": "Basia",
13+
"city": "London",
14+
"scores": [
15+
22,
16+
9,
17+
6
18+
]
19+
},
20+
{
21+
"name": "Mehmet",
22+
"city": "Birmingham",
23+
"scores": [
24+
3,
25+
12,
26+
17
27+
]
28+
},
29+
{
30+
"name": "Leila",
31+
"city": "London",
32+
"scores": [
33+
1
34+
]
35+
},
36+
{
37+
"name": "Piotr",
38+
"city": "Glasgow",
39+
"scores": [
40+
15,
41+
2,
42+
25,
43+
11,
44+
8
45+
]
46+
},
47+
{
48+
"name": "Chandra",
49+
"city": "Birmingham",
50+
"scores": [
51+
12,
52+
6
53+
]
54+
}
55+
]

jq/script-01.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ set -euo pipefail
55
# The input for this script is the person.json file.
66
# TODO: Write a command to output the name of the person.
77
# Your output should be exactly the string "Selma", but should not contain any quote characters.
8+
jq -r ' .name' person.json

jq/script-02.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ set -euo pipefail
55
# The input for this script is the person.json file.
66
# TODO: Write a command to output the address of the person, all on one line, with a comma between each line.
77
# Your output should be exactly the string "35 Fashion Street, London, E1 6PX", but should not contain any quote characters.
8+
jq '.address | join(", ")' person.json

jq/script-03.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ set -euo pipefail
55
# The input for this script is the person.json file.
66
# TODO: Write a command to output the name of the person, then a comma, then their profession.
77
# Your output should be exactly the string "Selma, Software Engineer", but should not contain any quote characters.
8+
jq '.name + ", " + .profession' person.json

jq/script-04.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ set -euo pipefail
66
# TODO: Write a command to output just the names of each player, one per line.
77
# Your output should contain 6 lines, each with just one word on it.
88
# Your output should not contain any quote characters.
9+
jq -r '.[] .name' scores.json

jq/script-05.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ set -euo pipefail
55
# The input for this script is the scores.json file.
66
# TODO: Write a command to output the names of each player, as well as their city.
77
# Your output should contain 6 lines, each with two words on it.
8+
jq '.[] | "\(.name) \(.city)"' scores.json

jq/script-06.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ set -euo pipefail
66
# TODO: Write a command to output just the names of each player along with the score from their first attempt.
77
# Your output should contain 6 lines, each with one word and one number on it.
88
# The first line should be "Ahmed 1" with no quotes.
9+
jq '.[] | "\(.name) \(.scores[0])"' scores.json

jq/script-07.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ set -euo pipefail
66
# TODO: Write a command to output just the names of each player along with the score from their last attempt.
77
# Your output should contain 6 lines, each with one word and one number on it.
88
# The first line should be "Ahmed 4" with no quotes.
9+
jq -r '.[] | "\(.name) \(.scores[-1])"' scores.json

jq/script-08.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ set -euo pipefail
66
# TODO: Write a command to output just the names of each player along with the number of times they've played the game.
77
# Your output should contain 6 lines, each with one word and one number on it.
88
# The first line should be "Ahmed 3" with no quotes.
9+
jq '.[] | "\(.name) \(.scores | length)"' scores.json

jq/script-09.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ set -euo pipefail
66
# TODO: Write a command to output just the names of each player along with the total scores from all of their games added together.
77
# Your output should contain 6 lines, each with one word and one number on it.
88
# The first line should be "Ahmed 15" with no quotes.
9+
jq '.[] | "\(.name) \(.scores | add)"' scores.json

0 commit comments

Comments
 (0)