Serialize whole Record
515382
def _serialize_record(self, record):
        """"""
        f = self._empty_to_dot
        row = [record.CHROM, record.POS]
        row.append(f(";".join(record.ID)))
        row.append(f(record.REF))
        if not record.ALT:
            row.append(".")
        else:
            row.append(",".join([f(a.serialize()) for a in record.ALT]))
        row.append(f(record.QUAL))
        row.append(f(";".join(record.FILTER)))
        row.append(f(self._serialize_info(record)))
        if record.FORMAT:
            row.append(":".join(record.FORMAT))
        row += [
            self._serialize_call(record.FORMAT, record.call_for_sample[s])
            for s in self.header.samples.names
        ]
        print(*row, sep="\t", file=self.stream)
668970
def serialize(self, value, primitive=False):
        """"""
        if hasattr(value, 'serialize'):
            # i.e. value is a nested model
            return value.serialize(primitive=primitive)
        else:
            return value
383755
def serialize(self):
        """"""
        # Serialize fields to a dict
        elements = []
        for element in self.elements:
            elements.append(element.serialize())
        data = {'type': 'document', 'elements': elements}
        return data
1295802
def dump_as_json(record, output_file):
    
    def default_func(value):
        """
        Default conversion for JSON value.
        """
        if isinstance(value, frozenset):
            return sorted(value)
        raise TypeError(repr(value) + " is not JSON serializable")

    converted_record = record._replace(
        ordered_statistics=[x._asdict() for x in record.ordered_statistics])
    json.dump(
        converted_record._asdict(), output_file,
        default=default_func, ensure_ascii=False)
    output_file.write(os.linesep)
132025
def _serialize(cls, key, value, fields):
        
        converter = cls._get_converter_for_field(key, None, fields)
        return converter.serialize(value)
936383
def _serialize_call(self, format_, call):
        """'"""
        if isinstance(call, record.UnparsedCall):
            return call.unparsed_data
        else:
            result = [
                format_value(self.header.get_format_field_info(key), call.data.get(key), "FORMAT")
                for key in format_
            ]
            return ":".join(result)
87099
def serialize(template, options=SerializerOptions()):
    """"""
    context = SerializerContext(options)
    context.serialize(flatten(template))
    return context.output
1164535
public void serializeToPagesWithoutLength(
			BinaryRow record,
			AbstractPagedOutputView out) throws IOException {
		int remainSize = record.getSizeInBytes();
		int posInSegOfRecord = record.getOffset();
		int segmentSize = record.getSegments()[0].size();
		for (MemorySegment segOfRecord : record.getSegments()) {
			int nWrite = Math.min(segmentSize - posInSegOfRecord, remainSize);
			assert nWrite > 0;
			out.write(segOfRecord, posInSegOfRecord, nWrite);

			// next new segment.
			posInSegOfRecord = 0;
			remainSize -= nWrite;
			if (remainSize == 0) {
				break;
			}
		}
		checkArgument(remainSize == 0);
	}
57958
def serialize(self):
        
        data = super(Note, self).serialize()
        data.update({
            "verb": "post",
            "object": {
                "objectType": self.object_type,
                "content": self.content,
            }
        })
        if self.display_name:
            data["object"]["displayName"] = self.display_name

        return data
1253223
def format(self, record):
        

        try:
            n = record.n
        except AttributeError:
            n = 'default'

        try:
            message = record.message
        except AttributeError:
            message = record.msg

        senml = OrderedDict(
            uid="hyperstream",
            bt=datetime.utcfromtimestamp(record.created).isoformat()[:-3] + 'Z',
            e=[OrderedDict(n=n, v=message)]
        )

        formatted_json = json.dumps(senml)
        return formatted_json
1226274
def serialize(self):
        """"""
        data = {'doc': self.doc}
        if isinstance(self.query, Query):
            data['query'] = self.query.serialize()
        return data
68565
@Deprecated
    @Override
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void serializeObject(JsonWriteGenericRecord record, String fieldName, String typeName, Object obj) {
        try {
            if (obj == null) {
                record.getGenerator().writeObjectField(fieldName, null);
                return;
            }
            if (isPrimitive(obj.getClass())) {
                serializePrimitive(record, fieldName, obj);
                return;
            }
            record.getGenerator().writeFieldName(fieldName);
            record.getGenerator().writeStartObject();

            NFTypeSerializer fieldSerializer = getSerializer(typeName);
            JsonWriteGenericRecord fieldRecord = new JsonWriteGenericRecord(record.getGenerator());
            fieldSerializer.serialize(obj, fieldRecord);
            record.getGenerator().writeEndObject();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
76019
def _serialize_info(self, record):
        """"""
        result = []
        for key, value in record.INFO.items():
            info = self.header.get_info_field_info(key)
            if info.type == "Flag":
                result.append(key)
            else:
                result.append("{}={}".format(key, format_value(info, value, "INFO")))
        return ";".join(result)
1246045
function serializeAllDates(model, json) {
	_.each(json, function (value, name) {
		if ( _.isDate( value ) ) {
			json[ name ] = model.serializeDate( name, value );
		} else if ( !isScalar( value ) && !isBackboneInstance( value ) && isRecursive( value ) ) {
			serializeAllDates( model, value );
		}
	});

	return json;
}
605742
@Override
	protected void serializeTo(RawDataBuffer out)
    {
        super.serializeTo(out);
        out.writeInt(sessionId.asInt());
    }
728453
@Override
	public int serializeToPages(
			BinaryRow record,
			AbstractPagedOutputView headerLessView) throws IOException {
		checkArgument(headerLessView.getHeaderLength() == 0);
		int sizeInBytes = record.getSizeInBytes();
		int skip = checkSkipWriteForFixLengthPart(headerLessView);
		if (record.getSegments().length == 1) {
			headerLessView.writeInt(sizeInBytes);
			headerLessView.write(record.getSegments()[0], record.getOffset(), sizeInBytes);
		} else {
			headerLessView.writeInt(record.getSizeInBytes());
			serializeToPagesWithoutLength(record, headerLessView);
		}
		return skip;
	}
1022872
def format_record(record):
    """"""

    record = dict(
        (key, getattr(record, key, None))
        for key in (
            "threadName",
            "name",
            "thread",
            "created",
            "process",
            "processName",
            "args",
            "module",
            "filename",
            "levelno",
            "exc_text",
            "pathname",
            "lineno",
            "msg",
            "exc_info",
            "funcName",
            "relativeCreated",
            "levelname",
            "msecs")
    )

    # Humanise output and conform to Exceptions
    record["message"] = str(record.pop("msg"))

    if os.getenv("PYBLISH_SAFE"):
        schema.validate(record, "record")

    return record