diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-11-10 11:07:54 +0100 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-11-10 11:07:54 +0100 |
commit | 1c068079574cd78c8bfd878f1d3fea5f54c7be98 (patch) | |
tree | 88ac563c49d29bd5ff987b8e22f46d8fe447a7d4 | |
parent | a19588719ccf0ec35d22acdf2ce349a5ef499691 (diff) |
process-response: optionally JSON array as vector, for instance desc
-rw-r--r-- | lisp/mastodon-http.el | 12 | ||||
-rw-r--r-- | lisp/mastodon-tl.el | 4 |
2 files changed, 9 insertions, 7 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 0866248..9525568 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -148,17 +148,17 @@ SILENT means don't message." "GET" (mastodon-http--url-retrieve-synchronously url silent))) -(defun mastodon-http--get-response (url &optional no-headers silent) +(defun mastodon-http--get-response (url &optional no-headers silent vector) "Make synchronous GET request to URL. Return JSON and response headers. SILENT means don't message. NO-HEADERS means don't collect http response headers." (with-current-buffer (mastodon-http--get url silent) - (mastodon-http--process-response no-headers))) + (mastodon-http--process-response no-headers vector))) -(defun mastodon-http--get-json (url &optional silent) +(defun mastodon-http--get-json (url &optional silent vector) "Return only JSON data from URL request. SILENT means don't message." - (car (mastodon-http--get-response url :no-headers silent))) + (car (mastodon-http--get-response url :no-headers silent vector))) (defun mastodon-http--process-json () "Return only JSON data from async URL request. @@ -166,7 +166,7 @@ Callback to `mastodon-http--get-json-async', usually `mastodon-tl--init*', is run on the result." (car (mastodon-http--process-response :no-headers))) -(defun mastodon-http--process-response (&optional no-headers) +(defun mastodon-http--process-response (&optional no-headers vector) "Process http response. Return a cons of JSON list and http response headers. If NO-HEADERS is non-nil, just return the JSON. @@ -178,7 +178,7 @@ Callback to `mastodon-http--get-response-async', usually (mastodon-http--process-headers)))) (goto-char (point-min)) (re-search-forward "^$" nil 'move) - (let ((json-array-type 'list) + (let ((json-array-type (if vector 'vector 'list)) (json-string (decode-coding-string (buffer-substring-no-properties (point) (point-max)) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 03ee41e..338f227 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1466,7 +1466,9 @@ INSTANCE is an instance domain name." (if user (mastodon-http--api "instance") (concat instance - "/api/v1/instance"))))) + "/api/v1/instance")) + nil + :vector))) (when response (let ((buf (get-buffer-create "*mastodon-instance*"))) (with-current-buffer buf |