Created
May 16, 2018 12:30
-
-
Save xBartu/4bdf327774ebc6a316168f2fb8d4c7a9 to your computer and use it in GitHub Desktop.
interv1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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