Serialize an object to a JSON formatted string.


    @param obj: an instance to convert to a JSON formatted string.

    @param trimmable: indicate whether null attributes of this object
        need to be stripped out the JSON formatted string.


        @return: a JSON formatted string.

def jsonify(obj, trimmable=False):
    """
    Serialize an object to a JSON formatted string.


    @param obj: an instance to convert to a JSON formatted string.

    @param trimmable: indicate whether null attributes of this object
        need to be stripped out the JSON formatted string.


        @return: a JSON formatted string.
    """
    # def jsonify_ex(obj, trimmable=False):
    #     if obj is None:
    #         return None
    #     elif isinstance(obj, (basestring, bool, int, long, float, complex)):
    #         return obj
    #     elif isinstance(obj, (list, set, tuple)):
    #         return [jsonify_ex(item, trimmable=trimmable) for item in obj] # MUST NOT remove nil value
    #     elif isinstance(obj, dict):
    #         return dict([(jsonify_ex(key, trimmable=trimmable), jsonify_ex(value, trimmable=trimmable))
    #                 for (key, value) in obj.iteritems() if not trimmable or value is not None])
    #     elif isinstance(obj, (uuid.UUID, EnumValue, ISO8601DateTime, Locale)):
    #         return str(obj)
    #     elif isinstance(obj, datetime.datetime):
    #         return str(ISO8601DateTime.from_datetime(obj)) if obj.tzinfo else str(obj)
    #     elif '__dict__' in dir(obj):
    #         return dict([(key, jsonify_ex(value, trimmable=trimmable))
    #                 for (key, value) in obj.__dict__.iteritems() if not trimmable or value is not None])
    #     else:
    #         return str(obj)
    #
    # return json.dumps(jsonify_ex(obj, trimmable=trimmable))
    return json.dumps(stringify(obj, trimmable=trimmable))