json_decode

 SYNOPSIS
  Parse JSON text into an S-Lang data structure

 USAGE
  json = json_decode (String_Type text)

 DESCRIPTION
  The `json_decode' function parses JSON data from the input
  string, and returns a corresponding S-Lang data structure.
  JSON values are represented as follows:

    JSON   -> S-Lang

    object    Struct_Type
    array     List_Type
    string    String_Type or BString_Type
    number    (L)Long_Type or Double_Type
    `true'    UChar_Type ('\1')
    `false'   UChar_Type ('\0')
    `null'    Null_Type

  The S-Lang structure corresponding to a JSON object
  with duplicate keys has no duplicate field names,
  but the field value is given by the last JSON value.

  If the input string does not contain valid JSON data,
  or if numeric values cannot be represented within S-Lang,
  or if JSON objects and/or arrays are too deeply nested,
  a `Json_Parse_Error' is thrown.

 SEE ALSO
  json_encode

--------------------------------------------------------------

json_encode

 SYNOPSIS
  Generate JSON text from an S-Lang data structure

 USAGE
  String_Type text = json_encode (json)

 DESCRIPTION
  The `json_encode' function generates the JSON text
  that corresponds to the S_Lang data structure `json'.
  Valid input types -- i.e., those that generate text
  that can be parsed by `json_decode' -- are Struct_Type
  (for JSON objects) and List_Type or Array_Type (for
  JSON arrays), provided that these containers contain
  only the following types:

    S-Lang                         -> JSON

    Struct_Type                       object
    List_Type or Array_Type           array
    String_Type or BString_Type       string
    UChar_Type ('\1')                 `true'
    UChar_Type ('\0')                 `false'
    other non-complex numeric types   number
    Null_Type                         `null'

  Invalid input causes a `Json_Invalid_Json_Error'.

  Optional whitespace in the output text can be configured
  by the `pre_nsep', `post_nsep', `pre_vsep', and `post_vsep'
  qualifiers. (Only strings built from ' ', '\t', '\n',
  or '\r' are allowed. Other characters are ignored.)
  If present, all whitespace after the final "\n"
  in `post_vsep' is considered as extra indentation,
  which accumulates for nested objects and arrays.

 QUALIFIERS
  ; pre_nsep=str: whitespace before name separator ':'
                    in objects (default: "")
  ; post_nsep=str: whitespace after name separator ':'
                     in objects (default: "")
  ; pre_vsep=str: whitespace before value separator ','
                    in objects or arrays (default: "")
  ; post_vsep=str: whitespace after value separator ',',
                     after the opening, and before
                     the closing brackets in objects
                     or arrays (default: "")

 EXAMPLE

  % some whitespace and indentation after separators:
  json_encode (json; pre_nsep="", post_nsep=" ",
                     pre_vsep="", post_vsep="\n  ")

  % yet more whitespace around separators:
  json_encode (json; pre_nsep=" ", post_nsep="  ",
                     pre_vsep=" ", post_vsep="\n\t")


 SEE ALSO
  json_decode

--------------------------------------------------------------
