# Path: deepstreampy/constants/types.py
# STRING = 'S'
# OBJECT = 'O'
# NUMBER = 'N'
# NULL = 'L'
# TRUE = 'T'
# FALSE = 'F'
# UNDEFINED = 'U'
# 
# Path: deepstreampy/constants/message.py
# MESSAGE_SEPERATOR = chr(30)  # ASCII Record Seperator 1E
# MESSAGE_PART_SEPERATOR = chr(31)  # ASCII Unit Separator 1F
# 
# Path: deepstreampy/utils.py
# class Undefined(object):
#     def __repr__(self):
#         return 'Undefined'


from deepstreampy.constants import types
from deepstreampy.constants import message as message_constants
from deepstreampy.utils import Undefined
import sys
import json

def typed(value):
    if value is None:
        return types.NULL

    value_type = type(value)

    if sys.version_info < (3,):
        num_types = (int, long, float, complex)
        str_types = (str, unicode)
    else:
        num_types = (int, float, complex)
        str_types = (str,)
    obj_types = (dict, list,)

    if value_type in str_types:
        return types.STRING + value

    if value_type in obj_types:
        return types.OBJECT + json.dumps(value,
                                         separators=(',', ':'),
                                         sort_keys=False)

    if value_type is bool:
        if value:
            return types.TRUE
        else:
            return types.FALSE

    if value_type in num_types:

# Path: deepstreampy/constants/types.py
# STRING = 'S'
# OBJECT = 'O'
# NUMBER = 'N'
# NULL = 'L'
# TRUE = 'T'
# FALSE = 'F'
# UNDEFINED = 'U'
# 
# Path: deepstreampy/constants/message.py
# MESSAGE_SEPERATOR = chr(30)  # ASCII Record Seperator 1E
# MESSAGE_PART_SEPERATOR = chr(31)  # ASCII Unit Separator 1F
# 
# Path: deepstreampy/utils.py
# class Undefined(object):
#     def __repr__(self):
#         return 'Undefined'


# Path: deepstreampy/message/message_builder.py
from deepstreampy.constants import types
from deepstreampy.constants import message as message_constants
from deepstreampy.utils import Undefined
import sys
import json


def typed(value):
    if value is None:
        return types.NULL

    value_type = type(value)

    if sys.version_info < (3,):
        num_types = (int, long, float, complex)
        str_types = (str, unicode)
    else:
        num_types = (int, float, complex)
        str_types = (str,)
    obj_types = (dict, list,)

    if value_type in str_types:
        return types.STRING + value

    if value_type in obj_types:
        return types.OBJECT + json.dumps(value,
                                         separators=(',', ':'),
                                         sort_keys=False)

    if value_type is bool:
        if value:
            return types.TRUE
        else:
            return types.FALSE

    if value_type in num_types:

        return types.NUMBER + str(value)