src/sagemaker_xgboost_container/encoder.py
def json_to_jsonlines(json_data):
    """Convert a json response to jsonlines.

    :param json_data: json data (dict or json string)
    :return: jsonlines encoded response (bytes)
    """
    resp_dict = json_data if isinstance(json_data, dict) else json.loads(json_data)

    if len(resp_dict.keys()) != 1:
        raise ValueError("JSON response is not compatible for conversion to jsonlines.")

    bio = io.BytesIO()
    for value in resp_dict.values():
        for entry in value:
            bio.write(bytes(json.dumps(entry) + "\n", "UTF-8"))
    return bio.getvalue()
Convert a json response to jsonlines.

    :param json_data: json data (dict or json string)
    :return: jsonlines encoded response (bytes)
    
Convert a json response to jsonlines.
Convert a json response to jsonlines .
def json_to_jsonlines(json_data):
    resp_dict = json_data if isinstance(json_data, dict) else json.loads(json_data)
    if len(resp_dict.keys()) != 1:
        raise ValueError("JSON response is not compatible for conversion to jsonlines.")
    bio = io.BytesIO()
    for value in resp_dict.values():
        for entry in value:
            bio.write(bytes(json.dumps(entry) + "\n", "UTF-8"))
    return bio.getvalue()
def json_to_jsonlines ( json_data ) : resp_dict = json_data if isinstance ( json_data , dict ) else json . loads ( json_data ) if len ( resp_dict . keys ( ) ) != 1 : raise ValueError ( "JSON response is not compatible for conversion to jsonlines." ) bio = io . BytesIO ( ) for value in resp_dict . values ( ) : for entry in value : bio . write ( bytes ( json . dumps ( entry ) + "\n" , "UTF-8" ) ) return bio . getvalue ( )
Convert a json response to jsonlines.
Convert a json response to jsonlines .
"""Convert a json response to jsonlines.

    :param json_data: json data (dict or json string)
    :return: jsonlines encoded response (bytes)
    """
jsonlines encoded response (bytes)
jsonlines encoded response ( bytes )
json_data
json data (dict or json string)
json data ( dict or json string )