classafBson::BsonIO
sys::Obj afBson::BsonIO
Reads and writes BSON documents to and from Streams and Bufs.
- print
- Str print(Obj? val, Int? maxWidth := null, Str? indent := null)- Pretty prints MongoDB documents to a JSON-esque string. Useful for debugging. - Note PrettyPrinter only pretty prints if the resulting text string if greater than - maxWidth. So if- PrettyPrinterappears not to be working, then try setting a smaller- maxWidth.- str := BsonIO.print(doc, 20) - maxWidthdefaults to- 80, and- indentto 2 spaces.
- readDoc
- Str:Obj? readDoc(InStream in, TimeZone tz := TimeZone.cur())- Reads a BSON document from an - InStream.- Notes: - BINARYobjects with a subtype of- BIN_GENERICare returned as a- Buf.
- CODEobjects are returned as- Strs.
- INTEGER_32values are returned as 64-bit- Ints.
- REGEXflags are converted to embedded character flags.
- Deprecated BSON objects are returned as null.
 - All - DATEobjects are returned in the given- TimeZone.- This does not change the instant in the date time continuum, just time zone it is reported in. This lets a stored date time of - 12 Dec 2012 18:00 UTCbe returned as- 12 Dec 2012 13:00 New_York.
- writeDoc
- Buf writeDoc(Str:Obj? document, Buf? buf := null)- Writes the BSON document to a Buf. - As per BSON spec, the returned - Bufis set to be little endian.