2.1 Network

Network-related functions.

Function: restlib-fetch-json URL
  • URL: string or URL object

Synchronously fetch the URL returning a deserialized JSON response.

The following is done with a URL whose response is in JSON:

  1. Synchronously fetch the URL.
  2. Upon success, deserialize the JSON into an Elisp hash-table, with JSON null values converted to nil.
  3. Return the JSON hash-table object.

Any failure in the HTTP request will raise an error message. Refer to Emacs Lisp Reference Manual for guidance on handling this condition ((elisp)Handling Errors).

Example:

(restlib-fetch-json "https://wttr.in/?0&format=j1")