Skip to content

EncodeError

Raised when encode is given a value that can't be written as JSON as it stands.

Example

let items = []
items.push $items
try
  encode {items: $items}
catch EncodeError: err
  echo "can't encode $(err.path): $err"

Inherits from: std.ValueError

Fields

kind @ (:CYCLE: | :RANGE: | :KEY:) [get]

Why the value can't be written.

Kind Meaning
:CYCLE: The value contains itself.
:RANGE: An Int is outside the signed 64-bit range.
:KEY: A Float key is not finite.
path @ Tuple[...Int | Str | Sym | Float | Bool] [get]

Keys and indices that lead from the encoded value to the fault.

For :CYCLE: the path leads to the repeated container, for :RANGE: to the Int, or to the object holding it when it is a key, and for :KEY: to the object holding the key. Each key is the one in the encoded value.