def dump_json(obj, path=None, indent=2):
    """Convert object to a JSON file or JSON string"""
    import json
    if path:
        with open(path, 'w') as handle:
            json.dump(obj, handle, indent=indent)
    else:
        return json.dumps(obj)
