Serialize the given object into into simple
        data types (e.g. lists, dictionaries, strings).
18694
def serialize(self, request):
        

        def serialize(anything):

            def serialize_dictionary(dictionary):
                """Dictionaries are serialized recursively."""
                data = OrderedDict()

                # Serialize each of the dictionary's keys
                for key, value in dictionary.items():
                    data.update({ key: serialize(value) })

                return data

            def serialize_list(list):
                """Lists are serialized recursively."""
                data = []

                # Serialize each of the list's items
                for item in list:
                    data.append(serialize(item))

                return data

            def serialize_queryset(queryset):
                """Querysets are serialized as lists of models."""
                data = []

                # Serialize queryset as a list of models
                for model in queryset:
                    data.append(serialize_model(model))

                return data

            def serialize_datequeryset(datequeryset):
                """DateQuerysets are serialized as lists of dates."""
                data = []

                # Serialize datequeryset as a list of datetime objects
                for date in datequeryset:
                    data.append(serialize_date(date))

                return data

            def serialize_valueslistqueryset(valueslistqueryset):
                """DateQuerysets are serialized as lists of values."""
                data = []

                # Serialize valueslistqueryset as a list of values
                for value in valueslistqueryset:
                    if isinstance(value, tuple):
                        data.append(serialize_list(value))
                    else:
                        data.append(serialize(value))

                return data

            def serialize_manager(manager):
                """Managers are serialized as list of models."""
                data = []

                for model in manager.all():
                    data.append(serialize_model(model))

                return data

            def serialize_model(model):
                """
                Models are serialized by calling their 'serialize' method.

                Models that don't define a 'serialize' method are
                serialized as a dictionary of fields.

                Example:

                    {
                        'id': 1,
                        'title': 'Mmmm pie',
                        'content: 'Pie is good!'
                    }

                """

                if hasattr(model, 'serialize'):
                    return serialize(model.serialize())
                else:
                    data = OrderedDict()
                    for field in model._meta.fields + model._meta.many_to_many:
                        data.update({
                            field.name: serialize(getattr(model, field.name ))
                        })

                    return data

            def serialize_form(form):
                """
                Forms are serialized as a dictionary of fields and errors (if any).

                Example:

                    {
                        'fields': ['title', 'content'],
                        'errors': {
                            'content': 'Must describe pie.'
                        }
                    }

                """
                data = OrderedDict()

                # Serialize form fields as a list of strings
                data['fields'] = []
                for field in form.fields:
                    data['fields'].append(field)

                # Serialize form errors as a dictionary with keys 'field' and 'error'
                if form.errors:
                    data['errors'] = []
                    for field in form:
                        data['errors'].append(
                            {
                                'field': field.name,
                                'error': field.errors.as_text()
                            }
                        )

                return data

            def serialize_date(datetime):
                """Dates are serialized as ISO 8601-compatible strings."""
                return datetime.isoformat()

            def serialize_field_file(field_file):
                """Filefields are serialized as strings describing their URL."""
                try:
                    return field_file.url
                except ValueError:
                    return None

            def serialize_image_field_file(image_field_file):
                """Imagefields are serialized as strings describing their URL."""
                try:
                    return image_field_file.url
                except ValueError:
                    return None

            def serialize_decimal_field(decimal_field):
                """Decimal fields are serialized as strings."""
                try:
                    return str(decimal_field)
                except ValueError:
                    return None

            if isinstance(anything, dict):
                return serialize_dictionary(anything)

            if isinstance(anything, (list, set)):
                return serialize_list(anything)

            if isinstance(anything, django.db.models.query.DateQuerySet):
                return serialize_datequeryset(anything)

            if isinstance(anything, django.db.models.query.DateTimeQuerySet):
                return serialize_datequeryset(anything)

            if isinstance(anything, django.db.models.query.ValuesListQuerySet):
                return serialize_valueslistqueryset(anything)

            if isinstance(anything, django.db.models.query.QuerySet):
                return serialize_queryset(anything)

            if isinstance(anything, django.db.models.Model):
                return serialize_model(anything)

            if isinstance(anything, (django.forms.Form, django.forms.ModelForm)):
                return serialize_form(anything)

            if isinstance(anything, (str, unicode)):
                return anything

            if isinstance(anything, (int, float, long)):
                return anything

            if isinstance(anything, (datetime.date, datetime.datetime)):
                return serialize_date(anything)

            if isinstance(anything, django.db.models.manager.Manager):
                return serialize_manager(anything)

            if isinstance(anything, Decimal):
                return serialize_decimal_field(anything)

            if isinstance(anything, django.core.files.base.File):
                return serialize_field_file(anything)

            if anything is None:
                return None

            if hasattr(anything, 'serialize'):
                return serialize(anything.serialize())

            raise TypeError("Respite doesn't know how to serialize %s" % anything.__class__.__name__)

        return serialize(self.source)
13658
def serialize(obj):
    """"""
    # Record class and module information for deserialization
    result = {'__class__': obj.__class__.__name__}
    try:
        result['__module__'] = obj.__module__
    except AttributeError:
        pass
    # Convert objects to dictionary representation based on type
    if isinstance(obj, datetime.datetime):
        result['year'] = obj.year
        result['month'] = obj.month
        result['day'] = obj.day
        result['hour'] = obj.hour
        result['minute'] = obj.minute
        result['second'] = obj.second
        result['microsecond'] = obj.microsecond
        return result
    if isinstance(obj, StreamingBody):
        result['body'] = obj.read()
        obj._raw_stream = StringIO(result['body'])
        obj._amount_read = 0
        return result
    # Raise a TypeError if the object isn't recognized
    raise TypeError("Type not serializable")
1110012
function __serializeObject(data, options=DEFAULT_OPTIONS) {
	let dataBuffers = [];
	let allKeys = (options.sort_key === true) ? Object.keys(data).sort() : Object.keys(data);
	// ignore undefined value
	for (let key of allKeys) {
		let subData = data[key];
		if (subData === undefined) continue;

		let subType = __getType(subData, options);
		let subTypeBuffer = __serializeType(subType);
		let keyBuffers = __serializeShortString(key);
		let subDataBuffers = __serializeData(subType, subData, options);
		dataBuffers.push(subTypeBuffer, ...keyBuffers, ...subDataBuffers);
	}
	let length = __getLengthByArrayBuffers(dataBuffers);
	let lengthData = new Uint32Array([length]);
	return [lengthData.buffer, ...dataBuffers];
}
360832
function serialize(obj) {
  var params = [],
    encodedBrackets = encodeURIComponent('[]');

  _.forOwn(obj, function(value, key) {
    if (typeof value === 'string' ||
      typeof value === 'number' ||
      typeof value === 'boolean') {
      params.push(key + '=' + encodeURIComponent(value));
    } else if (typeof value === 'object' && Array.isArray(value)) {
      params.push(value.map(function(param) {
        return key + encodedBrackets + '=' + encodeURIComponent(param);
      }).join('&'));
    }
  });

  return params.join('&');
}
462223
def to_dict(obj):
    
    if isinstance(obj, dict):
        return obj
    elif hasattr(obj, "to_dict"):
        return obj.to_dict()
    try:
        return simple_object_to_dict(obj)
    except:
        raise ValueError(
            "Cannot convert %s : %s to dictionary" % (
                obj, type(obj)))
105250
def serialize(d):
    
    ret = {}
    for k,v in d.items():
        if not k.startswith('_'):
            ret[k] = str(d[k])
    #ret['__class__'] = obj.__class__.__name__
    return ret
658657
def serialize(self, obj, fields):
        

        data = {}
        remaining_fields = []
        for field in fields:
            if callable(field):  # Callable
                data[field.__name__] = field(obj)
            elif hasattr(self, field) and callable(getattr(self, field)):  # Method on the view
                data[field] = getattr(self, field)(obj)
            elif hasattr(obj, field):  # Callable/property/field on the model
                attr = getattr(obj, field)
                if isinstance(attr, Model):
                    data[field] = attr.pk
                elif isinstance(attr, Manager):
                    data[field] = [item['pk'] for item in attr.values('pk')]
                elif callable(attr):  # Callable on the model
                    data[field] = attr()
                else:
                    remaining_fields.append(field)
            else:
                raise AttributeError('Invalid field: %s' % field)

        # Add on db fields
        serializer = Serializer()
        serializer.serialize([obj], fields=list(remaining_fields))
        data.update(serializer.getvalue()[0]['fields'])

        # Any remaining fields should be properties on the model
        remaining_fields = set(remaining_fields) - set(data.keys())

        for field in remaining_fields:
            data[field] = getattr(obj, field)

        return data
194215
def serialize(self):
        

        data = {}
        for k, v in self.iteritems():
            if k.startswith('_'):
                continue

            if isinstance(v, APIModel):
                data[k] = v.serialize()
            elif v and is_seq_not_string(v) and isinstance(v[0], APIModel):
                data[k] = [x.serialize() for x in v]
            else:
                data[k] = v

        return data
794342
def to_value(self, obj, resource, visited=set()):
        """"""

        if id(obj) in visited:
            raise ValueError('Circular reference detected when attempting to serialize object')

        if isinstance(obj, (list, tuple, set)):
            return [self.to_value(x, resource) if hasattr(x, '__dict__') else x for x in obj]
        elif hasattr(obj, '__dict__'):
            attrs = obj.__dict__.copy()
            for key in six.iterkeys(obj.__dict__):
                if key.startswith('_'):
                    del attrs[key]

            return {
                self.reverse_aliases.get(k, k):
                    self.to_value(v, resource) if hasattr(v, '__dict__') or isinstance(v, (list, tuple, set)) else v
                for k, v in six.iteritems(attrs)
            }
        else:
            return obj
969297
def encode(obj):
    
    if hasattr(obj, 'json'):
        return obj.json
    if hasattr(obj, '__json__'):
        return obj.__json__()
    return dumps(obj)
792280
function serialize(object) {
	function replacer(key, value) {
		if (typeof value === 'string' && value.match(ISO8601_DATE_REGEX)) {
			value = new Date(value);
			value = value.toISOString();
		}
		return value;
	}

	return JSON.stringify(object, replacer);
}
400376
def _serialize_iterable(obj):
    
    if isinstance(obj, (tuple, set)):
        # make a tuple assignable by casting it to list
        obj = list(obj)
    for item in obj:
        obj[obj.index(item)] = serialize_obj(item)
    return obj
390920
def serialize(self, obj):
        """"""
        if hasattr(obj, '_jsid'):
            return {'immutable': False, 'value': obj._jsid}
        else:
            obj_json = {'immutable': True}
            try:
                json.dumps(obj)
                obj_json['value'] = obj
            except:
                pass
            if callable(obj):
                guid = str(uuid.uuid4())
                callback_registry[guid] = obj
                obj_json['callback'] = guid
            return obj_json
245503
def object_to_json(obj):
    """"""
    if isinstance(obj, (datetime.datetime, datetime.date, datetime.time)):
        return obj.isoformat()
    return str(obj)
429515
def make_serializable(data):
    """"""
    if is_serializable(data):
        return data

    # if numpy array convert to list
    try:
        return data.tolist()
    except AttributeError:
        pass
    except Exception as e:
        logger.debug('{} exception ({}): {}'.format(type(e).__name__, e, data))

    # try serializing each child element
    if isinstance(data, dict):
        return {key: make_serializable(value) for key, value in data.items()}
    try:
        return [make_serializable(element) for element in data]
    except TypeError:  # not iterable
        pass
    except Exception:
        logger.debug('Could not serialize {}; converting to string'.format(data))

    # last resort: convert to string
    return str(data)
90539
public static byte[] serialize(Object object) {
		
		byte[] result = null;
		
		if (object == null) {
			return new byte[0];
		}
		try {
			ByteArrayOutputStream byteStream = new ByteArrayOutputStream(128);
			try  {
				if (!(object instanceof Serializable)) {
					throw new IllegalArgumentException(SerializeUtils.class.getSimpleName() + " requires a Serializable payload " +
							"but received an object of type [" + object.getClass().getName() + "]");
				}
				ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteStream);
				objectOutputStream.writeObject(object);
				objectOutputStream.flush();
				result =  byteStream.toByteArray();
			}
			catch (Throwable ex) {
				throw new Exception("Failed to serialize", ex);
			}
		} catch (Exception ex) {
			logger.error("Failed to serialize",ex);
		}
		return result;
	}
88284
def serialize(obj):
    
    if isinstance(obj, list):
        return [serialize(o) for o in obj]
    return GenericSerializer(ModelProviderImpl()).serialize(obj)