Skip to content

Instantly share code, notes, and snippets.

@xBartu
Created May 16, 2018 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xBartu/4bdf327774ebc6a316168f2fb8d4c7a9 to your computer and use it in GitHub Desktop.
Save xBartu/4bdf327774ebc6a316168f2fb8d4c7a9 to your computer and use it in GitHub Desktop.
interv1
res = []
def splitter(json):
global res
for key in json:
if type(json[key]) == type(dict()):
res.append(str(key))
splitter(json[key])
else:
res.append({key:json[key]})
dic = {"type": "articles",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!",
"body": "The shortest article. Ever.",
"created": "2015-05-22T14:56:29.000Z",
"updated": "2015-05-22T14:56:28.000Z"
},
"relationships": {
"author": {
"data": {"id": "42", "type": "people"}
}
}
}
splitter(dic)
print(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment