Created
March 26, 2021 06:53
-
-
Save Ricks-Lab/8c300d35d24fd6515e361eb830c53144 to your computer and use it in GitHub Desktop.
Pretty print a human readable and compliant json object from a dictionary
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 pprint | |
import re | |
def json_pprint(json_dict: dict) -> None: | |
""" Print human readable and compliant json file from dict representation of json. | |
This solution solves the problem of quote differences between dict and json | |
""" | |
print(re.sub(r'\'', '\"', | |
pprint.pformat(json_dict, indent=2, width=120, sort_dicts=False))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment