import json


def read_json_config(cfg):
    """Read a JSON configuration. First attempt to read as a JSON
    string. If that fails, assume that it is a JSON file and attempt
    to read contents from the file.

    Args:
        res: a config string or file path

    Returns:
        dict of config options
    """
    try:
        cfg = json.loads(cfg)
    except ValueError:
        cfg_file = open(cfg, 'r')
        cfg = json.load(cfg_file)

    return cfg