Fix ein:worksheet-to-json

When there is no metadata, do not include it in JSON data to avoid
converting nil to JSON (which yields null).
This commit is contained in:
Takafumi Arakaki 2012-08-30 00:36:44 +02:00
parent f1f94d772d
commit 0bf9cce4b7
2 changed files with 4 additions and 1 deletions

View file

@ -228,7 +228,7 @@ current buffer."
c (ein:funcall-packed discard-output-p c)))
(ein:worksheet-get-cells ws)))))
`((cells . ,(apply #'vector cells))
(metadata . ,(oref ws :metadata)))))
,@(ein:aand (oref ws :metadata) `((metadata . ,it))))))
(defmethod ein:worksheet-save-cells ((ws ein:worksheet))
"Save cells in worksheet buffer in cache before killing the buffer.

View file

@ -23,6 +23,9 @@
(ein:worksheet-from-json ws-1
(ein:json-read-from-string
(json-encode json-0))))))
(let* ((found (assoc 'metadata json-0)))
(when found
(should (cdr found))))
(should (equal json-0 json-1))))
(ert-deftest ein:worksheet-to-json/empty ()