diff --git a/.gitignore b/.gitignore index fe95ccc06a06fb48db3896e2950faa1113e40ec3..27cf7b0f5c713747eb3ed7a971a58e1f349097e8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ __pycache__ *.tmp *.open *.ini +*.json generators/*.csv diff --git a/config/json_parser.py b/config/json_parser.py new file mode 100644 index 0000000000000000000000000000000000000000..4e26f74aba8d2bfdf2c548f52ed71b8d1359ca2a --- /dev/null +++ b/config/json_parser.py @@ -0,0 +1,12 @@ +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)) + diff --git a/config/json_test.py b/config/json_test.py new file mode 100644 index 0000000000000000000000000000000000000000..9707a359271a0ebd92e6271a3ec55a34d816319b --- /dev/null +++ b/config/json_test.py @@ -0,0 +1,50 @@ +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)) +'''