Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use archive.json to populate the html package index, rather than ad-h…
…oc sexp parsing
- Loading branch information
Showing
4 changed files
with
47 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
;;; Fixes for json.el such that integer plist / alist keys are rendered as strings, in order to comply with the json spec | |||
|
|||
(require 'json) | |||
|
|||
(defun json-encode-key-value-pair (pair) | |||
"Encode a (key . value) PAIR as JSON, ensuring that key is encoded into a string." | |||
(let ((encoded-key (json-encode (car pair)))) | |||
(format "%s:%s" | |||
(if (string-match "^\"" encoded-key) | |||
encoded-key | |||
(json-encode-string encoded-key)) | |||
(json-encode (cdr pair))))) | |||
|
|||
(defun json-encode-hash-table (hash-table) | |||
"Return a JSON representation of HASH-TABLE." | |||
(json-encode-alist (maphash 'cons hash-table))) | |||
|
|||
;; List encoding (including alists and plists) | |||
|
|||
(defun json-encode-alist (alist) | |||
"Return a JSON representation of ALIST." | |||
(format "{%s}" | |||
(json-join (mapcar 'json-encode-key-value-pair | |||
alist) ", "))) | |||
|
|||
(defun json-encode-plist (plist) | |||
"Return a JSON representation of PLIST." | |||
(json-encode-alist | |||
(loop while plist | |||
collect (cons (car plist) (cadr plist)) | |||
do (setf plist (cddr plist))))) | |||
|
|||
|
|||
(provide 'json-fix) | |||
;;; json-fix.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters