Introducing json.el (original) (raw)

JSON is a lightweight data interchange format based on a subset of JavaScript. You can read all about JSON at json.org.json.el is a JSON parser and generator for Emacs Lisp, which can produce an Emacs Lisp data structure from a JSON object and vice-versa. It’s been Included with Emacs since February 2008.

Using it is pretty straightforward; here are some examples.

JSON's primitive values are strings, numbers, and the keywordstrue, false, and null.

JSON's compound values are arrays and dictionaries.

Notice that we read the JSON array as a lisp vector and the JSON dictionary as an alist. We could just have read the array as a list, and the dictionary as a plist or hashtable. json.el allows for all of these representations. (Also, note that the alist keys are symbols; we could read these as keywords or strings.)

#<hash-table 'equal nil 1/65 0x314f800>

json.el generally does the right thing when encoding idiomatic lisp data structures: