The define-json-expander Reference Manual

This is the define-json-expander Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sat Dec 03 21:17:24 2022 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 define-json-expander

Small facility for converting between JSON and CLOS

Author

Johan Sjölén

License

MIT

Source

define-json-expander.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 define-json-expander/define-json-expander.asd

Source

define-json-expander.asd.

Parent Component

define-json-expander (system).

ASDF Systems

define-json-expander.


3.1.2 define-json-expander/package.lisp

Source

define-json-expander.asd.

Parent Component

define-json-expander (system).

Packages

define-json-expander.


3.1.3 define-json-expander/define-json-expander.lisp

Dependency

package.lisp (file).

Source

define-json-expander.asd.

Parent Component

define-json-expander (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 define-json-expander

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *accessor-prefix*
Package

define-json-expander.

Source

define-json-expander.lisp.


5.1.2 Macros

Macro: define-json-expander (name direct-superclasses direct-slots &rest options)
Package

define-json-expander.

Source

define-json-expander.lisp.


5.2 Internals


5.2.1 Macros

Macro: define-json-decoder (name &rest slot/json-list)

Generates a decoder function with the name decode-‘name’
The ‘slot/json-list’ is of the form (slot-name json-property-name &optional decoder-function) where slot-name refers to the slot’s initarg
decoder-function refers to the function which will be called upon a structure if so provided

The decoder automatically takes all unused JSON-properties and puts them into the rest slot

Example definition and expansion:
(define-4chan-decoder post
(:no :no)
(:name :name)
(:e-mail :email)
(:body :com)
(:date :time))
(DEFUN DECODE-POST (POST)
"Takes a JSON document in list form and decodes it into a CLOS POST object"
(FLET ((P (KEY)
(CDR (ASSOC KEY POST))))
(MAKE-INSTANCE ’POST :NO (P :NO) :NAME (P :NAME) :E-MAIL (P :EMAIL) :BODY
(P :COM) :DATE (P :TIME) :REST
(REMOVE-IF
(LAMBDA (ELT)
(MEMBER (CAR ELT)
’((:NO :NO) (:NAME :NAME) (:E-MAIL :EMAIL)
(:BODY :COM) (:DATE :TIME))
:KEY #’CADR :TEST #’EQ))
POST))))

Package

define-json-expander.

Source

define-json-expander.lisp.


5.2.2 Ordinary functions

Function: clean-option (direct-slot option)

Returns two values, the first being the ‘direct-slot’ with the ‘option’ and its value stripped and the second being a list consisting of the name of the slot and the found prop and value. If such a prop isn’t found then the second element is NIL.

Package

define-json-expander.

Source

define-json-expander.lisp.

Function: clean-options (slots &rest options)

Cleans several options from several slots.

Package

define-json-expander.

Source

define-json-expander.lisp.

Function: flatten-n-times (tree &optional n)

Flatten a tree by n levels of subtrees. n = 1 doesn’t flatten at all.

Package

define-json-expander.

Source

define-json-expander.lisp.

Function: get-prop (symbol list)
Package

define-json-expander.

Source

define-json-expander.lisp.

Function: group (source n)
Package

define-json-expander.

Source

define-json-expander.lisp.


Appendix A Indexes


A.1 Concepts


A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*accessor-prefix*: Public special variables

S
Special Variable, *accessor-prefix*: Public special variables