Idris2Doc : JSON.Value

JSON.Value

(source)
The interfaces in this module abstract over how we
encode and decode values from and to JSON.

This allows us to use different (probably backend dependant)
intermediary data representations to be used by the actual
marshallers `ToJSON` and `FromJSON`.

Definitions

maxSafeInteger : Integer
  In Javascript, numbers are represented as IEEE 64bit
floating point numbers. Integers can be represented exactly
in the range [-(2^53-1), 2^53-1]. This library's default
behavior is, that large integers will be encoded as
`string` and smaller values use `number`

Visibility: public export
interfaceEncoder : Type->Type
  Abstraction over JSON value encoding.

Parameters: v
Methods:
stringify : v->String
  Converts the intermediary data representation
to a JSON string.
string : String->v
  Encodes a `String` value.
number : Double->v
  Encodes a `Double` as a JSON `Number`.
boolean : Bool->v
  Encodes a `Bool` as a JSON `Boolean`.
array : Listv->v
  Encodes a `List` of values as a JSON `Array`.
object : List (String, v) ->v
  Encodes a `List` key-value pairs as a JSON `Object`
null : v

Implementation: 
EncoderJSON
stringify : Encoderv=>v->String
  Converts the intermediary data representation
to a JSON string.

Visibility: public export
string : Encoderv=>String->v
  Encodes a `String` value.

Visibility: public export
number : Encoderv=>Double->v
  Encodes a `Double` as a JSON `Number`.

Visibility: public export
boolean : Encoderv=>Bool->v
  Encodes a `Bool` as a JSON `Boolean`.

Visibility: public export
array : Encoderv=>Listv->v
  Encodes a `List` of values as a JSON `Array`.

Visibility: public export
object : Encoderv=>List (String, v) ->v
  Encodes a `List` key-value pairs as a JSON `Object`

Visibility: public export
null : Encoderv=>v
Visibility: public export
smallInteger : Encoderv=>Integer->v
  Encode a small integer (less than or equal to `maxSafeInteger`)
as a number.

Visibility: export
largeInteger : Encoderv=>Integer->v
  Encode an `Integer` (possibly larger than `masSafeInteger`)
as a number or a string.

The corresponding decoder for potentially large numbers
will also try both types: Number and string.

Visibility: export
interfaceObject : Type->Type->Type
  Abstraction over JSON Object representation for decoding.
It is important that `obj` is the type that guides interface
resolution here, otherwise operators like `.:` cannot conveniently
be used, since Idris needs additional guidance to resolve interfaces.

Parameters: obj, v
Methods:
lookup : String->obj->Maybev

Implementation: 
Object (List (String, JSON)) JSON
lookup : Objectobjv=>String->obj->Maybev
Visibility: public export
interfaceValue : Type->Type->Type
  Abstraction over JSON value representation for decoding.

Parameters: v, obj
Constraints: Object obj v
Methods:
typeOf : v->String
  Returns the actual value. This should be one of
"String", "Null", "Object", "Number", "Boolean", or "Array".
However, other types are possible as well, as this is
only used for error messages when something goes wrong.
parse : String->EitherParseErrv
  Tries to convert a string to an intermediare value.
getObject : v->Maybeobj
  Tries to convert a value to an `Object`.
getArray : v->Maybe (Listv)
  Tries to convert a value to an `Array` of values.
getBoolean : v->MaybeBool
  Tries to convert a value to a `Boolean`.
getNumber : v->MaybeDouble
  Tries to convert a value to a `Number`.
getString : v->MaybeString
  Tries to convert a value to a `String`.
isNull : v->Bool
  `True`, if the value in question is `null`.

Implementation: 
ValueJSON (List (String, JSON))
typeOf : Valuevobj=>v->String
  Returns the actual value. This should be one of
"String", "Null", "Object", "Number", "Boolean", or "Array".
However, other types are possible as well, as this is
only used for error messages when something goes wrong.

Visibility: public export
parse : Valuevobj=>String->EitherParseErrv
  Tries to convert a string to an intermediare value.

Visibility: public export
getObject : Valuevobj=>v->Maybeobj
  Tries to convert a value to an `Object`.

Visibility: public export
getArray : Valuevobj=>v->Maybe (Listv)
  Tries to convert a value to an `Array` of values.

Visibility: public export
getBoolean : Valuevobj=>v->MaybeBool
  Tries to convert a value to a `Boolean`.

Visibility: public export
getNumber : Valuevobj=>v->MaybeDouble
  Tries to convert a value to a `Number`.

Visibility: public export
getString : Valuevobj=>v->MaybeString
  Tries to convert a value to a `String`.

Visibility: public export
isNull : Valuevobj=>v->Bool
  `True`, if the value in question is `null`.

Visibility: public export