src/streamlink/utils/__init__.py
def parse_json(data, name="JSON", exception=PluginError, schema=None):
    """Wrapper around json.loads.

    Wraps errors in custom exception with a snippet of the data in the message.
    """
    try:
        json_data = json.loads(data)
    except ValueError as err:
        snippet = repr(data)
        if len(snippet) > 35:
            snippet = snippet[:35] + " ..."
        else:
            snippet = data

        raise exception("Unable to parse {0}: {1} ({2})".format(name, err, snippet))

    if schema:
        json_data = schema.validate(json_data, name=name, exception=exception)

    return json_data
def parse_json(data, name="JSON", exception=PluginError, schema=None):
    """Wrapper around json.loads.

    Wraps errors in custom exception with a snippet of the data in the message.
    """
    try:
        json_data = json.loads(data)
    except ValueError as err:
        snippet = repr(data)
        if len(snippet) > 35:
            snippet = snippet[:35] + " ..."
        else:
            snippet = data

        raise exception("Unable to parse {0}: {1} ({2})".format(name, err, snippet))

    if schema:
        json_data = schema.validate(json_data, name=name, exception=exception)

    return json_data
def parse_json ( data , name = "JSON" , exception = PluginError , schema = None ) : try : json_data = json . loads ( data ) except ValueError as err : snippet = repr ( data ) if len ( snippet ) > 35 : snippet = snippet [ : 35 ] + " ..." else : snippet = data raise exception ( "Unable to parse {0}: {1} ({2})" . format ( name , err , snippet ) ) if schema : json_data = schema . validate ( json_data , name = name , exception = exception ) return json_data
Wrapper around json.loads.

    Wraps errors in custom exception with a snippet of the data in the message.
Wrapper around json . loads .