#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
# ──────────────────────────────────────────────────────────────────────────────
# $source: cappysan-dotfile-scripts$
# ──────────────────────────────────────────────────────────────────────────────
#
# NAME
#      dict2json - convert python3 dict to json
#
# SEE ALSO
#      jq(1)
#
import ast
import json
import sys

try:
    data = open(0).read()
    if not data:
        sys.exit(0)
    data = ast.literal_eval(data)
    print(json.dumps(data, indent=2))
except (ValueError, SyntaxError) as err:
    print(err, file=sys.stderr)
    sys.exit(1)
