By default, jzon serializes a standard-object as a JSON object using its bound slots as keys. You can control how nil values are serialized by specifying a :type on the slot. This is useful for ensuring that empty or missing data conforms to a specific JSON schema.
Nil resolution rules based on :type:
boolean $\rightarrow$ falselist $\rightarrow$ []null $\rightarrow$ null (this is also the default if no type is specified)
Example:
If a class has a slot married with :type boolean, a nil value will serialize to false. If a slot children has :type list, nil will serialize to [].
(defclass person ()
((married :initarg :married :type boolean)
(children :initarg :children :type list)
(job :initarg :job)))
;; Serializing a person with nil values:
(jzon:stringify (make-instance 'person :name "Anya" :job nil :married nil :children nil)
:pretty t :stream t)
;; Resulting JSON:
;; {
;; "name": "Anya",
;; "job": null,
;; "married": false,
;; "children": []
;; }