Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
p0l4r authored Mar 3, 2020
1 parent 941e434 commit 756d83f
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
5 changes: 5 additions & 0 deletions example_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"fruit": "Apple",
"size": "Large",
"color": "Red"
}
1 change: 1 addition & 0 deletions example_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"color": "Red", "fruit": "Apple", "size": "Large"}
3 changes: 3 additions & 0 deletions example_2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
color: Red
fruit: Apple
size: Large
26 changes: 26 additions & 0 deletions json to ymal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#author: Shantanu Kumar Rahut
#email: [email protected]

import simplejson as json
import yaml as yaml

print("Loading json Data...")
#opening json file in read mode
f = open('example_1.json','r')
print("Saving json Data...")
#loading json data in a variable
jsondata = json.load(f)
print("Closing File...")
#closing the file
f.close()
print("json Data Loading Finished...")


#opening yaml file in write mode
ff = open('example_2.yaml','w+')
print("Data Dumping from json to yaml Started...")
#dumping data from json to yaml
yaml.dump(jsondata,ff,allow_unicode=True)
print("Data Dumping from json to yaml Finished...")
#closing file
ff.close()
31 changes: 31 additions & 0 deletions yaml to json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#author: Shantanu Kumar Rahut
#email: [email protected]

import simplejson as json
import yaml as yaml

print("Loading yaml Data...")
#opening yaml file in read mode
f = open('example_2.yaml','r')
print("Saving yaml Data...")
#loading yaml data in a variable
yamldata = yaml.safe_load(f)
print("Closing File...")
#closing the file
f.close()
print("yaml Data Loading Finished...")


#opening json file in write mode
ff = open('example_2.json','w+')
print("Data Dumping from yaml to json Started...")
#dumping data from yaml to json
json.dump(yamldata,ff, ensure_ascii=False)
print("Data Dumping from yaml to json Finished...")
#closing file
ff.close()





0 comments on commit 756d83f

Please sign in to comment.