import json


def json_load(obj, error=True, **kwargs):
    """Deserialize a json str into an object.

    Args:
        obj (:obj:`object`): str to deserialize into obj
        error (:obj:`bool`, optional): default ``True`` -

            * if ``True`` If json error happens, raise it
            * if ``False`` If json error happens, return original obj as is
        **kwargs: passed to :func:`json.loads`

    Returns:
        :obj:`object`: json str serialized into python obj
    """
    try:
        return json.loads(obj, **kwargs)
    except Exception:
        if error:
            raise
        return obj