Generic formatter (parser/printer).

Not limited to parsing from/printing to strings, but designed to work with any type of data, even for binary decoding/encoding.

Dunaj provides following built-in formatters:

  • utf-8/utf-16/charset-formatter - parsers and printers

  • clj/edn/json - parsers and printers

  • lazy-clj/lazy-edn/lazy-json - lazy parsers

  • pretty-clj/pretty-edn/pretty-json - pretty printers

  • string - a printf like printer

  • regular expression - parsing regexes

  • html - basic html printer

default-formatter-batch-size

Available since version 1.0 (view source)

not referred automatically

VAR of type Var

A dynamic var holding default formatter batch size.

parse

Available since version 1.0 (view source)

RETURNS TRANSDUCER

Usage:
  • (parse parser)

  • (parse parser coll)

Type signatures:
  • (IParserFactory) → Transducer

  • (IParserFactory ⨯ []) → IRed

Returns a transducer that parses step items, with parser used for parsing. Returns recipe if coll is given.

See also: parser?, parse-whole

parse-whole

Available since version 1.0 (view source)

Usage:
  • (parse-whole parser coll)

Type signature:
  • (IParserFactory ⨯ IRed) → Any

Returns one item parsed from coll, with parser used for parsing. Entire collection must parse into one result item. Throws if none or multiple objects were parsed.

See also: parser?, parse

parser?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (parser? x)

Type signature: Predicate

Returns true if object x satisfies IParserFactory protocol, false otherwise.

print

Available since version 1.0 (view source)

RETURNS TRANSDUCER

Usage:
  • (print printer)

  • (print printer coll)

  • (print printer item & items)

Type signatures:
  • (IPrinterFactory) → Transducer

  • (IPrinterFactory ⨯ []) → IRed

  • (IPrinterFactory ⨯ Any ⨯ (Va Any)) → IRed

Returns a transducer which prints step items items or returns recipe of printed items if coll is supplied.

See also: printer?, print-one

Available since version 1.0 (view source)

Usage:
  • (print-one printer item)

Type signature:
  • (IPrinterFactory ⨯ Any) → IRed

Returns a reducible collection of one printed item, with printer used for printing.

See also: printer?, print

printer?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (printer? x)

Type signature: Predicate

Returns true if object x satisfies IPrinterFactory protocol, false otherwise.