Skip to content

Latest commit

 

History

History
43 lines (39 loc) · 993 Bytes

convert-python-dict-to-json.md

File metadata and controls

43 lines (39 loc) · 993 Bytes
aliases category classification date date_modified draft id image links local_archive_links pinned print series tags title type
convert-python-dict-to-json
python
public
2020-01-04 07:20:16 -0800
2020-01-04 07:20:16 -0800
false
20200104152016
false
false
python
dict
json
Convert Python Dictionary to JSON
tech-note
import json

example_dictionary = {
    'query': 'Genesis 1:1',
    'canonical': 'Genesis 1:1',
    'parsed': [[1001001, 1001001]],
    'passage_meta': [{
        'canonical': 'Genesis 1:1',
        'chapter_start': [1001001, 1001031],
        'chapter_end': [1001001, 1001031],
        'prev_verse': None,
        'next_verse': 1001002,
        'prev_chapter': None,
        'next_chapter': [1002001, 1002025]
        }],
    'passages': ['The Creation of the World\n\n  In the beginning, God created the heavens and the earth. (ESV)']
    }

example_json = json.dumps(example_dictionary, sort_keys=True, indent=4)
print(example_json)