package orsetto

  1. Overview
  2. Docs
A library of assorted structured data interchange languages

Install

Dune Dependency

Authors

Maintainers

Sources

r1.1.2.tar.gz
sha512=e260412b2dd0f98cfe3dc7ed5c31a694eb31c93cd207c51fa12675b790234ee0ad3bf07d9be17a4dc266fedfe55b14c967cad7bc0c9414063eef8afd59f3d0d1

doc/orsetto.json/Json_emit/Opaque/index.html

Module Json_emit.Opaque

A submodule containing logic for emitting JSON texts from values of type Cf_type.opaque according to optional mode selectors.

type mode

The mode selectors for emitting JSON texts from opaque values.

val mode : unit -> mode

Use mode () to create a mode selector record for the opaque value emitter. Use any of the various optional parameters to set a mode selector to other than its default value.

No selector modes are defined at present.

val value : ?mode:mode -> unit -> Cf_type.opaque t

Use value () to create an opaque value emitter. The following table describes the runtime type indications required for values emitted.

  • null: Cf_type.Unit
  • boolean: Cf_type.Bool
  • number: Cf_type.Int or Cf_type.Float
  • string: Cf_type.String or Ucs_type.Text
  • array: Cf_type.(Seq Opaque)
  • object: Cf_type.(Seq (Pair (Opaque, Opaque))

Use the ~mode parameter to select modes other than the default. Raises Invalid_argument if the witnessed type is not valid for output as a JSON value.

Note well: the first opaque value of each pair element in an object value must be witness either by Ucs_type.Text or Cf_type.String.

val to_text : ?mode:mode -> Cf_type.opaque -> Ucs_text.t

Use to_text v to format v as a Unicode text. Use ~mode to select the encoding modes. Raises Invalid_argument if v was not witnessed with a type compatible with JSON encoding.

OCaml

Innovation. Community. Security.