Serialize an object into the inline section.
323936
@Override
  public void write(TextWriterStream out, String label, Object object) {
    String res = (label != null) ? label + "=" : "";
    if(object != null) {
      if(label != null) {
        res += object.toString().replace(" ", "");
      }
      else {
        res += object.toString();
      }
    }
    out.inlinePrintNoQuotes(res);
  }
476390
def _serialize(
            self,
            element,  # type: ET.Element
            value,  # type: Any
            state  # type: _ProcessorState
    ):
        # type: (...) -> None
        """"""
        xml_value = _hooks_apply_before_serialize(self._hooks, state, value)

        # A value is only considered missing, and hence eligible to be replaced by its
        # default only if it is None. Falsey values are not considered missing and are
        # not replaced by the default.
        if xml_value is None:
            if self._default is None:
                serialized_value = Text('')
            else:
                serialized_value = Text(self._default)
        else:
            serialized_value = Text(xml_value)

        if self._attribute:
            element.set(self._attribute, serialized_value)
        else:
            element.text = serialized_value
84624
def dump(obj, fp, **kwargs):
    """"""

    s = dumps(obj, **kwargs)
    fp.write(str(s))
159410
def serialize(self, value, **kwargs):
        """"""
        return [self.item_type.serialize(val, **kwargs) for val in value]
695193
public void serializeBean(Object obj, Set<String> attributesToIgnore) {
        builder.newIndentedline();
        try {
            BeanInfo info = Introspector.getBeanInfo(obj.getClass());
            List<NameValue> values = new ArrayList<>();

            for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
                if (pd.getName().equals("class")) continue;
                Object value = pd.getReadMethod().invoke(obj);
                if (value == null) continue;
                if (value instanceof List && ((List) value).isEmpty()) continue;
                String attribute = getAttributeForField(pd.getName());
                if (!attributesToIgnore.contains(attribute)) {
                    values.add(new NameValue(attribute, value, value instanceof List && isPlainType(((List) value).get(0))));
                }
            }

            for (int i = 0; i < values.size(); i++) {
                NameValue value = values.get(i);
                builder.append(value.name).append(" = ");
                if (value.plain) {
                    serializePlain(value.value);
                } else {
                    serialize(value.value);
                }
                if (i < values.size() - 1) {
                    builder.newline();
                }

            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        builder.unindent().newline();
    }
656225
public void writeObjectOrNull (Output output, Object object, Serializer serializer) {
		if (output == null) throw new IllegalArgumentException("output cannot be null.");
		if (serializer == null) throw new IllegalArgumentException("serializer cannot be null.");
		beginObject();
		try {
			if (references) {
				if (writeReferenceOrNull(output, object, true)) return;
			} else if (!serializer.getAcceptsNull()) {
				if (object == null) {
					if (TRACE || (DEBUG && depth == 1)) log("Write", null, output.position());
					output.writeByte(NULL);
					return;
				}
				if (TRACE) trace("kryo", "Write: <not null>" + pos(output.position()));
				output.writeByte(NOT_NULL);
			}
			if (TRACE || (DEBUG && depth == 1)) log("Write", object, output.position());
			serializer.write(this, output, object);
		} finally {
			if (--depth == 0 && autoReset) reset();
		}
	}
394698
def stringify(self, obj, beautify=False, raise_exception=False):
        """"""

        return self.helper.string.serialization.json.stringify(
            obj=obj,
            beautify=beautify,
            raise_exception=raise_exception)
582277
def dump_inline_table(self, section):
        
        retval = ""
        if isinstance(section, dict):
            val_list = []
            for k, v in section.items():
                val = self.dump_inline_table(v)
                val_list.append(k + " = " + val)
            retval += "{ " + ", ".join(val_list) + " }\n"
            return retval
        else:
            return unicode(self.dump_value(section))
448307
public Object serialize(Object obj, String contentType, Map<String, Object> formParams) throws ApiException {
    if (contentType.startsWith("multipart/form-data")) {
      FormDataMultiPart mp = new FormDataMultiPart();
      for (Entry<String, Object> param: formParams.entrySet()) {
        if (param.getValue() instanceof File) {
          File file = (File) param.getValue();
          mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE));
        } else {
          mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE);
        }
      }
      return mp;
    } else if (contentType.startsWith("application/x-www-form-urlencoded")) {
      return this.getXWWWFormUrlencodedParams(formParams);
    } else if (contentType.startsWith("text/csv")) {
      return this.serializeToCsv(obj);
    } else {
      // We let Jersey attempt to serialize the body
      return obj;
    }
  }
565684
private final void serializeObjectNoSCO(Object v, ZooFieldDef def) {
        // Write class/null info
        if (v == null) {
            writeClassInfo(null, null);
            return;
        }
        
        //Persistent capable objects do not need to be serialized here.
        //If they should be serialized, then it will happen in serializeFields()
        Class<? extends Object> cls = v.getClass();
        writeClassInfo(cls, v);

        if (isPersistentCapable(cls)) {
            serializeOid(v);
            return;
        } else if (String.class == cls) {
        	String s = (String)v; 
        	out.writeString(s);
            return;
        } else if (Date.class == cls) {
            out.writeLong(((Date) v).getTime());
            return;
        } else if (GenericObject.class == cls) {
        	serializeOidGo((GenericObject) v);
        	return;
        }
        
        throw new IllegalArgumentException("Illegal class: " + cls + " from " + def);
    }
889008
def _to_representation(self, instance):
        """"""

        if self.enable_optimization:
            representation = self._faster_to_representation(instance)
        else:
            representation = super(
                WithDynamicSerializerMixin,
                self
            ).to_representation(instance)

        if settings.ENABLE_LINKS:
            # TODO: Make this function configurable to support other
            #       formats like JSON API link objects.
            representation = merge_link_object(
                self, representation, instance
            )

        if self.debug:
            representation['_meta'] = {
                'id': instance.pk,
                'type': self.get_plural_name()
            }

        # tag the representation with the serializer and instance
        return tag_dict(
            representation,
            serializer=self,
            instance=instance,
            embed=self.embed
        )
565003
def dumps(obj):
    """"""
    return json.dumps(obj, indent=4, sort_keys=True, cls=CustomEncoder)
924528
static private String serialize(Throwable ex, int depth, int level)
    {
        StringBuffer buff = new StringBuffer();
        String str = ex.toString();

        // Split the first line if it's too long
        int pos = str.indexOf(":");
        if(str.length() < 80 || pos == -1)
        {
            buff.append(str);
        }
        else
        {
            String str1 = str.substring(0, pos);
            String str2 = str.substring(pos+2);
            if(str2.indexOf(str1) == -1)
            {
                buff.append(str1);
                buff.append(": \n\t");
            }
            buff.append(str2);
        }

        if(depth > 0)
        {
            StackTraceElement[] elements = ex.getStackTrace();
            for(int i = 0; i < elements.length; i++)
            {
                buff.append("\n\tat ");
                buff.append(elements[i]);
                if(i == (depth-1) && elements.length > depth)
                {
                    buff.append("\n\t... "+(elements.length-depth)+" more ...");
                    i = elements.length;
                }
            }
        }

        if(ex.getCause() != null && level < 3)
        {
            buff.append("\nCaused by: ");
            buff.append(serialize(ex.getCause(), depth, ++level));
        }

        return buff.toString();
    }
1075893
def serialize(self, value, **kwargs):
        """"""
        kwargs.update({'include_class': kwargs.get('include_class', True)})
        if self.serializer is not None:
            return self.serializer(value, **kwargs)
        if value is None:
            return None
        serial_list = [self.prop.serialize(val, **kwargs)
                       for val in value]
        return serial_list
1257477
def _serialize(self, value, attr, obj):
        """"""
        try:
            return super(DateString, self)._serialize(
                arrow.get(value).date(), attr, obj)
        except ParserError:
            return missing
991743
def serialize_all(obj):
        """"""
        if '_hyperparameters' not in dir(obj):
            return {}
        return {k: str(v) for k, v in obj._hyperparameters.items() if v is not None}
130887
def serialize(obj, **options):
    '''
    
    '''

    try:
        if 'file_out' in options:
            return toml.dump(obj, options['file_out'], **options)
        else:
            return toml.dumps(obj, **options)
    except Exception as error:
        raise SerializationError(error)