Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SRC OBDH TMTC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robin Mueller
SRC OBDH TMTC
Commits
9b4943d8
Commit
9b4943d8
authored
4 years ago
by
Hoang Sa Nguyen
Browse files
Options
Downloads
Patches
Plain Diff
json parser
parent
803c58d7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
config/json_parser.py
+12
-0
12 additions, 0 deletions
config/json_parser.py
config/json_test.py
+50
-0
50 additions, 0 deletions
config/json_test.py
with
63 additions
and
0 deletions
.gitignore
+
1
−
0
View file @
9b4943d8
...
...
@@ -17,6 +17,7 @@ __pycache__
*.tmp
*.open
*.ini
*.json
generators/*.csv
...
...
This diff is collapsed.
Click to expand it.
config/json_parser.py
0 → 100644
+
12
−
0
View file @
9b4943d8
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))
This diff is collapsed.
Click to expand it.
config/json_test.py
0 → 100644
+
50
−
0
View file @
9b4943d8
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))
'''
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment