const classafMongo::PrettyPrinter
sys::Obj afMongo::PrettyPrinter
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 PrettyPrinter
appears not to be working, then try setting a smaller maxWidth
.
str := PrettyPrinter { maxWidth=20 }.print(mongoDoc)
- convertHook
virtual Obj? convertHook(Obj? val)
A simple override hook to alter values before they are printed.
By default this just returns the given value.
- indent
const Str indent := " "
The indent string used to indent the document.
- make
new make(|This? f := null)
Creates a
PrettyPrinter
with the default pretty printing options. May be either aPrettyPrintOptions
instance, or justfalse
to disable pretty printing.printer := PrettyPrinter() printer := PrettyPrinter { it.indent="\t"; it.maxWidth=40; }
- maxWidth
const Int maxWidth := 80
The maximum width of a list or map before it is broken up into separate lines.
- prettyPrint
const Bool prettyPrint := true
Set to
false
to disable pretty printing and have documents printed on a single line.- print
Pretty prints the given MongoDB object / document to a
Str
.str := prettyPrinter.print(mongoDoc)
- printToStream
This printToStream(Obj? obj, OutStream out)
Pretty prints the given MongoDB object / document to a stream.
prettyPrinter.print(mongoDoc, out)