yason

API Reference

yason

JSON parser/encoder

YASON

  • Generic-Function ENCODE (object &optional stream)
    Encode OBJECT to STREAM in JSON format. May be specialized by applications to perform specific rendering. STREAM defaults to *STANDARD-OUTPUT*.
  • Method ENCODE ((object integer) &optional (stream *standard-output*))
  • Method ENCODE ((object hash-table) &optional (stream *standard-output*))
  • Method ENCODE ((object vector) &optional (stream *standard-output*))
  • Method ENCODE ((object list) &optional (stream *standard-output*))
  • Function ENCODE-ALIST (object &optional (stream *standard-output*))
  • Function ENCODE-PLIST (object &optional (stream *standard-output*))
  • Generic-Function MAKE-JSON-OUTPUT-STREAM (stream &key indent)
  • Method MAKE-JSON-OUTPUT-STREAM (stream &key (indent t))
    Create a JSON output stream with indentation enabled.
  • Macro WITH-OUTPUT ((stream &rest args &key indent) &body body)
  • Macro WITH-OUTPUT-TO-STRING* ((&rest args &key indent) &body body)
    Set up a JSON streaming encoder context, then evaluate BODY. Return a string with the generated JSON output.
  • Condition NO-JSON-OUTPUT-CONTEXT  (ERROR)
    This condition is signalled when one of the stream encoding function is used outside the dynamic context of a WITH-OUTPUT or WITH-OUTPUT-TO-STRING* body.
  • Macro WITH-ARRAY (nil &body body)
    Open a JSON array, then run BODY. Inside the body, ENCODE-ARRAY-ELEMENT must be called to encode elements to the opened array. Must be called within an existing JSON encoder context, see WITH-OUTPUT and WITH-OUTPUT-TO-STRING*.
  • Macro WITH-OBJECT (nil &body body)
    Open a JSON object, then run BODY. Inside the body, ENCODE-OBJECT-ELEMENT or WITH-OBJECT-ELEMENT must be called to encode elements to the object. Must be called within an existing JSON encoder context, see WITH-OUTPUT and WITH-OUTPUT-TO-STRING*.
  • Function ENCODE-ARRAY-ELEMENT (object)
    Encode OBJECT as next array element to the last JSON array opened with WITH-ARRAY in the dynamic context. OBJECT is encoded using the ENCODE generic function, so it must be of a type for which an ENCODE method is defined.
  • Function ENCODE-ARRAY-ELEMENTS (&rest objects)
    Encode OBJECTS, a list of JSON encodable objects, as array elements.
  • Function ENCODE-OBJECT-ELEMENT (key value)
    Encode KEY and VALUE as object element to the last JSON object opened with WITH-OBJECT in the dynamic context. KEY and VALUE are encoded using the ENCODE generic function, so they both must be of a type for which an ENCODE method is defined.
  • Function ENCODE-OBJECT-ELEMENTS (&rest elements)
    Encode plist ELEMENTS as object elements.
  • Function ENCODE-OBJECT-SLOTS (object slots)
    For each slot in SLOTS, encode that slot on OBJECT as an object element. Equivalent to calling ENCODE-OBJECT-ELEMENT for each slot where the key is the slot name, and the value is the (SLOT-VALUE OBJECT slot)
  • Macro WITH-OBJECT-ELEMENT ((key) &body body)
    Open a new encoding context to encode a JSON object element. KEY is the key of the element. The value will be whatever BODY serializes to the current JSON output context using one of the stream encoding functions. This can be used to stream out nested object structures.
  • Generic-Function ENCODE-SLOTS (object)
    Generic function to encode object slots. It should be called in an object encoding context. It uses PROGN combinatation with MOST-SPECIFIC-LAST order, so that base class slots are encoded before derived class slots.
  • Generic-Function ENCODE-OBJECT (object)
    Generic function to encode an object. The default implementation opens a new object encoding context and calls ENCODE-SLOTS on the argument.
  • Method ENCODE-OBJECT (object)
  • Method ENCODE-OBJECT (object)
  • Method ENCODE-OBJECT (object)
  • Variable *PARSE-OBJECT-KEY-FN*
    #'identity
    Function to call to convert a key string in a JSON array to a key in the CL hash produced.
  • Variable *PARSE-JSON-ARRAYS-AS-VECTORS*
    nil
    If set to a true value, JSON arrays will be parsed as vectors, not as lists.
  • Variable *PARSE-JSON-BOOLEANS-AS-SYMBOLS*
    nil
    If set to a true value, JSON booleans will be read as the symbols TRUE and FALSE, not as T and NIL, respectively.
  • Variable *PARSE-JSON-NULL-AS-KEYWORD*
    nil
    If set to a true value, JSON nulls will be read as the keyword :NULL, not as NIL.
  • Variable *PARSE-OBJECT-AS*
    :hash-table
    Set to either :hash-table, :plist or :alist to determine the data structure that objects are parsed to.
  • Variable *PARSE-OBJECT-AS-ALIST*
    nil
    DEPRECATED, provided for backward compatibility
  • Function PARSE (input &key (object-key-fn *parse-object-key-fn*) (object-as *parse-object-as*) (json-arrays-as-vectors *parse-json-arrays-as-vectors*) (json-booleans-as-symbols *parse-json-booleans-as-symbols*) (json-nulls-as-keyword *parse-json-null-as-keyword*))
    Parse INPUT, which needs to be a string or a stream, as JSON. Returns the lisp representation of the JSON structure parsed. The keyword arguments can be used to override the parser settings as defined by the respective special variables.

Also exports

  • COMMON-LISP:NULL