Skip to content

About

A JSON Readtable for Common Lisp

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

A JSON Readtable for Common Lisp

Usage Example:

CL-USER> (asdf:load-system "json-readtable")
=> T

CL-USER> (use-package :json-readtable)
=> T

CL-USER> (let ((*readtable* *json-readtable*))
           (gethash
            "Hello, World!"
            (read-from-string "{\"Hello, World!\": [3.14, true, false, null]}")))
=> #(3.14 T NIL :NULL)

CL-USER> (with-json-readtable (:object :plist
                               :array :list
                               :true "apple"
                               :false "banana"
                               :null 'yum)
           (read-from-string "{\"Hello, World!\": [3.14, true, false, null]}"))
=> ("Hello, World!" (3.14 "apple" "banana" YUM))
=> 44

Embedding of JSON values in Common Lisp

  • Set *JSON-OBJECT* to :HASH-TABLE (default), :ALIST, or :PLIST
  • Set *JSON-ARRAY* to :VECTOR (default) or :LIST
  • Set *JSON-TRUE*, *JSON-FALSE*, *JSON-NULL* to your desired values.

Known bugs and implementation constraints

  • If the first non-whitespace char of a stream is not ASCII, behavior is implementation dependent. It’s reasonable to check that
    (FIND (PEEK-CHAR T STREAM NIL NIL NIL) "{[\"-0123456789tfn")
        

    is true before a top-level read.

  • We assume host implements CL:CHAR-CODE and CL:CODE-CHAR using Unicode code points.
  • This library may trigger bugs in Slime or Sly due to readtable conflicts.
  • This code was developed on SBCL and may have issues on untested implementations.

About

A JSON Readtable for Common Lisp

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages