import json


def make_json(data_dict, simple=None):
    """Make well formatted JSON for insertion into cascade word docs.

    JSON will be enclosed by '$ like: '${"key":"value"}$'
    JSON will be on one line (simple) if it contains only one key/value pair, or if
         the argument simple==true
    """
    if simple is None:
        # Default to simple as long as the JSON contains only one item and
        # that items is not a dict.
        simple = False
        if len(data_dict) <= 1:
            for key in data_dict:
                if not isinstance(data_dict[key], dict):
                    simple = True

    if simple:
        return '${}$'.format(json.dumps(data_dict, separators=(', ', ':')))
    return '${}$'.format(json.dumps(data_dict, indent=4, separators=(',', ':'))).replace('${\n  ', '${')