Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
18
Task/JSON/Emacs-Lisp/json-1.l
Normal file
18
Task/JSON/Emacs-Lisp/json-1.l
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
(require 'cl-lib)
|
||||
|
||||
(cl-assert (fboundp 'json-parse-string))
|
||||
(cl-assert (fboundp 'json-serialize))
|
||||
|
||||
(defvar example "{\"foo\": \"bar\", \"baz\": [1, 2, 3]}")
|
||||
(defvar example-object '((foo . "bar") (baz . [1 2 3])))
|
||||
|
||||
;; decoding
|
||||
(json-parse-string example) ;=> #s(hash-table [...]))
|
||||
;; using json.el-style options
|
||||
(json-parse-string example :object-type 'alist :null-object nil :false-object :json-false)
|
||||
;;=> ((foo . "bar") (baz . [1 2 3]))
|
||||
;; using plists for objects
|
||||
(json-parse-string example :object-type 'plist) ;=> (:foo "bar" :baz [1 2 3])
|
||||
|
||||
;; encoding
|
||||
(json-serialize example-object) ;=> "{\"foo\":\"bar\",\"baz\":[1,2,3]}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue