Skip to content

Instantly share code, notes, and snippets.

@zeddee
Created November 6, 2018 15:53
Show Gist options
  • Save zeddee/e3bc18541cd63d11006b7ecacf0c00bf to your computer and use it in GitHub Desktop.
Save zeddee/e3bc18541cd63d11006b7ecacf0c00bf to your computer and use it in GitHub Desktop.
manipulating json with python
{
"article": [
{
"id":"01",
"language": "JSON",
"edition": "first",
"author": "Derrick Mwiti"
},
{
"id":"02",
"language": "Python",
"edition": "second",
"author": "Derrick Mwiti"
}
],
"blog":[
{
"name": "Datacamp",
"URL":"datacamp.com"
}
]
}
import json
with open("./data.json","r") as f:
#o = f.read()
jsondata = json.load(f)
output = jsondata["blog"]
print(output)
jsonObj = {
"url": "datacamp.com",
"name": "datacamp"
}
with open("./jsondump.json","w") as f:
f.write(json.dumps(jsonObj))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment