Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to force 'false' boolean output when encoding JSON #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion doc/cl-json.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ <h3 class="section"><a name="DEFAULT-OPERATION"></a> The default encoder / decod
<td><code class="json-literal">null</code></td></tr>
<tr>
<td class="map">&larr;<span class="cc"> </span></td>
<td><code class="json-literal">false</code></td></tr>
<td rowspan="2"><code class="json-literal">false</code></td></tr>
<tr><td>the value of <code class="lisp">JSON:*JSON-FALSE*</code></td>
<td class="map">&rarr;</td></tr>
<tr><td>any other <code class="lisp-type">symbol</code></td>
<td class="map">&rarr;<span class="cc"> <br/>with identifier name translation </span></td>
<td rowspan="2"><code class="json">String</code></td></tr>
Expand Down
8 changes: 7 additions & 1 deletion src/common.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,18 @@ slash.")

;;; Symbols

(defparameter +json-lisp-symbol-tokens+
(defparameter *json-false* :false "Symbol to use to force output of JSON false value.")

(defparameter +json-lisp-symbol-tokens-real+
'(("true" . t)
("null" . nil)
("false" . nil))
"Mapping between JSON literal names and Lisp boolean values.")

(define-symbol-macro +json-lisp-symbol-tokens+
(append +json-lisp-symbol-tokens-real+
`(("false" . ,*json-false*))))

(defvar *json-symbols-package* (find-package 'keyword)
"The package where JSON Object keys etc. are interned.
Default KEYWORD, NIL = use current *PACKAGE*.")
Expand Down
1 change: 1 addition & 0 deletions src/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#:bind-custom-vars
#:set-custom-vars
#:*use-strict-json-rules*
#:*json-false*
#:*json-symbols-package*
#:json-intern
#:unknown-symbol-error
Expand Down