import json


def to_json(data):
    """ Convert any type to json serializable object """

    if isinstance(data, str):
        return data

    try:
        return json.dumps(data, ensure_ascii=False)
    except TypeError:
        return str(data)