Skip to content
Snippets Groups Projects
Commit 9b4943d8 authored by Hoang Sa Nguyen's avatar Hoang Sa Nguyen
Browse files

json parser

parent 803c58d7
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ __pycache__
*.tmp
*.open
*.ini
*.json
generators/*.csv
......
import json
com_port_data = {
"com1": "test"
}
with open("tmtcc_config.json", "w") as write:
json.dump(com_port_data, write, indent=4)
#with open("data_file.json", "r") as read_content:
# print(json.load(read_content))
import json
'''
people_string = {
"people": [
{
"name": "John Smith",
"phone": "615-555-7164",
"emails": ["johnsmith@bogusemail.com", "john.smith@work-place.com"],
"has_license": False
},
{
"name": "John Doe",
"phone": "111-666-7164",
"emails": ["johndoe@bogusemail.com", "john.doe@work-place.com"],
"has_license": True
}
]
}
data = {
"name": "Satyam kumar",
"place": "patna",
"skills": [
"Raspberry pi",
"Machine Learning",
"Web Development"
],
"email": "xyz@gmail.com",
"projects": [
"Python Data Mining",
"Python Data Science"
]
}
with open("data_file.json", "w") as write:
json.dump(data, write)
with open("data_file.json", "r") as read_content:
print(json.load(read_content))
with open("test.json", "w") as f:
json.dump(people_string, f, indent=4)
with open("test.json", "r") as f2:
test_data = json.load(f2)
#print(json.load(f2))
print(test_data)
print(type(test_data))
'''
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment