public interface JsonWriter
Document
representation.
The modified JSON format is nearly identical to the JSON serialization used by MongoDB. All standard JSON values are written as expected, but the types unique to BSON are written as follows:
BSON Type | Class | Format | Example |
---|---|---|---|
Symbol | Symbol |
"value" | "The quick brown fox" |
Regular Expression | Pattern |
{ "$regex" : "pattern", "$options" : "flags" } | { "$regex" : "[CH]at\sin", "$options" : "im" } |
Date | Date |
{ "$date" : "yyyy-MM-ddTHH:mm:ssZ" } | { "$date" : "2011-06-11T08:44:25Z" } |
Timestamp | Timestamp |
{ "$ts" : timeValue, "$inc" : incValue } | "\/TS("2011-06-11T08:44:25Z")\/" |
ObjectId | ObjectId |
{ "$oid" : "12bytesOfIdInBase16" } | { "$oid" : "0000012c0000c8000900000f" } |
Binary | Binary |
{ "$type" : typeAsInt, "$base64" : "bytesInBase64" }" | { "$type" : 0, "$base64" : "TWFuIGlzIGRpc3R" }" |
UUID | UUID |
{ "$uuid" : "string-form-of-uuid" } | { "$uuid" : "09e0e949-bba4-459c-bb1d-9352e5ee8958" } |
Code | Code |
{ "$code" : "code" } | { "$code" : "244-I2" } |
CodeWithScope | CodeWithScope |
{ "$code" : "code", "$scope" : scope document } | { "$code" : "244-I2", "$scope" : { "name" : "Joe" } } |
MinKey | MinKey |
"MinKey" | "MinKey" |
MaxKey | MaxKey |
"MaxKey" | "MaxKey" |
Null value | null | null |
Modifier and Type | Method and Description |
---|---|
String |
write(Object object)
Write and return the modified JSON representation of the supplied in-memory
Document . |
void |
write(Object object,
OutputStream stream)
Write to the supplied stream the modified JSON representation of the supplied in-memory
Document . |
void |
write(Object object,
StringBuilder builder)
Write to the supplied string builder the modified JSON representation of the supplied in-memory
Document . |
void |
write(Object object,
Writer writer)
Write to the supplied writer the modified JSON representation of the supplied in-memory
Document . |
void write(Object object, OutputStream stream) throws IOException
Document
.object
- the BSON object or BSON value; may not be nullstream
- the output stream; may not be nullIOException
- if there was a problem reading from the streamvoid write(Object object, Writer writer) throws IOException
Document
.object
- the BSON object or BSON value; may not be nullwriter
- the writer; may not be nullIOException
- if there was a problem reading from the streamvoid write(Object object, StringBuilder builder)
Document
.object
- the BSON object or BSON value; may not be nullbuilder
- the string builder; may not be nullCopyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.