Skip to content

Commit fdbfacb

Browse files
Add files via upload
Skeleton code to use python to parse json files.
1 parent c3476a0 commit fdbfacb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

json-parser_1.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import requests
2+
import json
3+
4+
5+
URL = "https://jsonplaceholder.typicode.com/users"
6+
7+
print("Search by Username:")
8+
9+
user = input("> ")
10+
11+
queryURL = URL + f"?username={user}"
12+
13+
response = requests.get(queryURL)
14+
15+
userdata = json.loads(response.text)[0]
16+
17+
name = userdata["name"]
18+
email = userdata["email"]
19+
phone = userdata["phone"]
20+
21+
print(f"{name} can be reached via the following methods:")
22+
print(f"Email: {email}")
23+
print(f"Phone: {phone}")

0 commit comments

Comments
 (0)