Module Jsonm.Uncut

module Uncut: sig .. end

Codec with comments and whitespace.

The uncut codec also processes whitespace and JavaScript comments. The latter is non-standard JSON, fail on `Comment decoding if you want to process whitespace but stick to the standard.

The uncut codec preserves as much of the original input as possible. Perfect round-trip with Jsonm is however impossible for the following reasons:


Uncut data model

The uncut data model is the same as the regular data model, except that before or after any lexeme you may decode/encode one or more:

Warning. Uncut.val-encode does not check the above constraints on w and c.

Decode

val decode : Jsonm.decoder ->
[ `Await
| `Comment of [ `M | `S ] * string
| `End
| `Error of Jsonm.error
| `Lexeme of Jsonm.lexeme
| `White of string ]

decode d is like Jsonm.val-decode but for the uncut data model.

val pp_decode : Stdlib.Format.formatter ->
[< `Await
| `Comment of [ `M | `S ] * string
| `End
| `Error of Jsonm.error
| `Lexeme of Jsonm.lexeme
| `White of string ] ->
unit

pp_decode ppf v prints an unspecified representation of v on ppf.

Encode

val encode : Jsonm.encoder ->
[< `Await
| `Comment of [ `M | `S ] * string
| `End
| `Lexeme of Jsonm.lexeme
| `White of string ] ->
[ `Ok | `Partial ]

encode is like Jsonm.val-encode but for the uncut data model.

IMPORTANT. Never encode `Comment for the web, it is non-standard and breaks interoperability.