;;; json.el --- JavaScript Object Notation parser / generator
-;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: Edward O'Connor <ted@oconnor.cx>
;; Version: 1.2
(defvar json-object-type 'alist
"Type to convert JSON objects to.
-Must be one of `alist', `plist', or `hash-table'. Consider let-binding
+Must be one of `alist', `plist', or `hash-table'. Consider let-binding
this around your call to `json-read' instead of `setq'ing it.")
(defvar json-array-type 'vector
"Type to convert JSON arrays to.
-Must be one of `vector' or `list'. Consider let-binding this around
+Must be one of `vector' or `list'. Consider let-binding this around
your call to `json-read' instead of `setq'ing it.")
(defvar json-key-type nil
`plist' `keyword'
Note that values other than `string' might behave strangely for
-Sufficiently Weird keys. Consider let-binding this around your call to
+Sufficiently Weird keys. Consider let-binding this around your call to
`json-read' instead of `setq'ing it.")
(defvar json-false :json-false
"Value to use when reading JSON `false'.
If this has the same value as `json-null', you might not be able to tell
-the difference between `false' and `null'. Consider let-binding this
+the difference between `false' and `null'. Consider let-binding this
around your call to `json-read' instead of `setq'ing it.")
(defvar json-null nil
"Value to use when reading JSON `null'.
If this has the same value as `json-false', you might not be able to
-tell the difference between `false' and `null'. Consider let-binding
+tell the difference between `false' and `null'. Consider let-binding
this around your call to `json-read' instead of `setq'ing it.")
\f
(defsubst json-advance (&optional n)
"Skip past the following N characters."
- (unless n (setq n 1))
- (let ((goal (+ (point) n)))
- (goto-char goal)
- (when (< (point) goal)
- (signal 'end-of-file nil))))
+ (forward-char n))
(defsubst json-peek ()
"Return the character at point."
(defun json-skip-whitespace ()
"Skip past the whitespace at point."
- (while (looking-at "[\t\r\n\f\b ]")
- (goto-char (match-end 0))))
+ (skip-chars-forward "\t\r\n\f\b "))
\f
(defun json-read-number (&optional sign)
"Read the JSON number following point.
-The optional SIGN argument is for internal use.
+The optional SIGN argument is for internal use.
N.B.: Only numbers which can fit in Emacs Lisp's native number
representation will be parsed correctly."