Serialize as a String
502222
public String toJson()
      throws IOException {
    StringWriter writer = new StringWriter();
    try (JsonGenerator generator = jsonFactory.createJsonGenerator(writer)
        .setCodec(objectMapper)) {
      toJsonUtf8(generator);
    }

    return writer.toString();
  }
1370401
function serialize(value, indent) {
    "use strict";
    if (isArray(value)) {
        value = value.map(function _map(prop) {
            return isFunction(prop) ? prop.toString().replace(/\s{2,}/, '') : prop;
        });
    }
    return JSON.stringify(value, null, indent);
}
1324488
def serialize(obj):
    """"""
    if isinstance(obj, datetime.datetime):
        serial = obj.isoformat(sep='T')
        return serial

    if isinstance(obj, uuid.UUID):
        serial = str(obj)
        return serial

    try:
        return obj.__dict__
    except AttributeError:
        return str(obj)
    except Exception as e:
        strval = 'unknown obj'
        exceptval = 'unknown err'
        try:
            strval = str(obj)
            exceptval = repr(e)
        except Exception:
            pass
        return 'json fail {} {}'.format(exceptval, strval)
1374097
def Serialize(self, val, info):
      
      self._Serialize(val, info, self.defaultNS)
1110080
def serialize(self, buf=None, lineLength=75, validate=True, behavior=None):
        
        if not behavior:
            behavior = self.behavior

        if behavior:
            if DEBUG:
                logger.debug("serializing {0!s} with behavior {1!s}".format(self.name, behavior))
            return behavior.serialize(self, buf, lineLength, validate)
        else:
            if DEBUG:
                logger.debug("serializing {0!s} without behavior".format(self.name))
            return defaultSerialize(self, buf, lineLength)
87099
def serialize(template, options=SerializerOptions()):
    """"""
    context = SerializerContext(options)
    context.serialize(flatten(template))
    return context.output
745899
def as_strings(self):
        """"""
        if self.value == '' or self.value is None:
            return '{0};\n'.format(self.name)
        if '"' not in self.value and (';' in self.value or '#' in self.value):
            return '{0} "{1}";\n'.format(self.name, self.value)
        return '{0} {1};\n'.format(self.name, self.value)
217740
def serialize(self):
        """"""
        if type(self.value) == int:
            return "i{:X}s".format(self.value).encode('ascii')

        if type(self.value) == str:
            value = self.value.encode('utf-8')
            return "{:X}:".format(len(value)).encode('ascii') + value

        if type(self.value) == bytes:
            value = base64.standard_b64encode(self.value)
            return "u{:X}:".format(len(value)).encode('ascii') + value

        if type(self.value) == list:
            items = [LiveMessageToken(m).serialize() for m in self.value]
            return b'l' + b''.join(items) + b's'

        if type(self.value) == dict:
            items = []
            for key, value in self.value.items():
                items.append(LiveMessageToken(str(key)).serialize())
                items.append(LiveMessageToken(value).serialize())
            return b'h' + b''.join(items) + b's'

        raise RuntimeError("Unknown type %s" % type(self.value))
1187526
def serialize(self, data):
        '''
        
        '''
        self.set_header('Content-Type', self.content_type)

        return self.dumper(data)
197731
protected static String serialize(Serializable serializable) throws JMSException {
        if (serializable == null) {
            return null;
        }
        String serializedString;
        ObjectOutputStream objectOutputStream = null;
        try {
            ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
            objectOutputStream = new ObjectOutputStream(bytesOut);
            objectOutputStream.writeObject(serializable);
            objectOutputStream.flush();
            serializedString = Base64.encodeAsString(bytesOut.toByteArray());
        } catch (IOException e) {
            LOG.error("IOException: cannot serialize objectMessage", e);
            throw convertExceptionToMessageFormatException(e);
        } finally {
            if (objectOutputStream != null) {
                try {
                    objectOutputStream.close();
                } catch (IOException e) {
                    LOG.warn(e.getMessage());
                }
            }
        }
        return serializedString;
    }
767272
function serialize(value) {
  if (Array.isArray(value) === true) {
    return serializeArray(value);
  }
  if (isObject(value) === false) {
    return serializePrimitive(value);
  }
  return serializeObject(value);
}
1012574
def to_string(self, value):
        """"""
        if isinstance(value, six.binary_type):
            value = value.decode('utf-8')
        return self.to_json(value)
1328387
def to_json(self, *args, **kwargs):
        
        return json.dumps(self.serialized, *args, **kwargs)
951646
function serializeIntoEqualString(obj) {

        var out = '';

        _.forEach(obj, function(val, key) {
            var stringVal;

            try {
                stringVal = JSON.stringify(val, safeCycles());
            } catch (e) {
                if (safeJsonStringify) {
                    stringVal = safeJsonStringify(val);
                } else {
                    stringVal = 'unserializable! you can install ' +
                                '"safe-json"stringify" module for safer ' +
                                'stringification';
                }
            }

            out += key + '=' + stringVal + ', ';
        });
        // remove last comma
        return out.slice(0, -2);
    }
951099
function serialize(input) {
    const value = JSON.stringify(input);
    return value === undefined
        ? reject(new Error(`Unsupported type ${type(input)}`))
        : resolve(value);
}
1117468
String serialize(Object o) {
        String body;
        try {
            body = new String(JsonSerializer.serialize(o));
        } catch (IOException e) {
            throw new ServiceException(ErrorCode.HTTP_CLIENT_ERROR,
                    ErrorCode.HTTP_CLIENT_ERROR.getMessageTemplate(),
                    "serialize failed.");
        }
        return body;
    }
722212
def encode_json(self, serializable):
        
        return json.dumps(serializable.serialize(), cls=self.encoder)