Created
June 8, 2019 01:39
-
-
Save johnxx/15cb14add6652ac2103a52d483caa0bc to your computer and use it in GitHub Desktop.
This file contains 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
import jsonstreams | |
with jsonstreams.Stream(jsonstreams.Type.object, filename='foo') as my_file: | |
my_dict = { | |
'Name': 'Pants', | |
'Color': 'khaki', | |
} | |
for k, v in my_dict.iteritems(): | |
my_file.write(k, v) | |
with my_file.subobject('Folders') as sub: | |
sub_dict = { | |
'Name': 'Pocket', | |
'Color': 'Invisible' | |
} | |
with sub.subobject(sub_dict['Name']) as sub_item: | |
for k, v in sub_dict.iteritems(): | |
sub_item.write(k, v) | |
with sub_item.subobject('Folders') as subsub: | |
subsub_dict = { | |
'Name': 'Lint', | |
'Color': 'Pants' | |
} | |
with subsub.subobject(subsub_dict['Name']) as subsub_item: | |
for k, v in subsub_dict.iteritems(): | |
subsub_item.write(k, v) |
Author
johnxx
commented
Jun 8, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment