blob: 6ccf6cb50db674b444b39036d8308cc64d417ab1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<h4 class="subsection">JSONRPC JSON object format</h4> <p>JSONRPC JSON objects are exchanged as Lisp plists (see <a href="property-lists">Property Lists</a>): JSON-compatible plists are handed to the dispatcher functions and, likewise, JSON-compatible plists should be given to <code>jsonrpc-notify</code>, <code>jsonrpc-request</code>, and <code>jsonrpc-async-request</code>. </p> <p>To facilitate handling plists, this library makes liberal use of <code>cl-lib</code> library (see <a href="https://www.gnu.org/software/emacs/manual/html_node/cl/index.html#Top">cl-lib</a> in <cite>Common Lisp Extensions for GNU Emacs Lisp</cite>) and suggests (but doesn’t force) its clients to do the same. A macro <code>jsonrpc-lambda</code> can be used to create a lambda for destructuring a JSON-object like in this example: </p> <div class="example"> <pre class="example">(jsonrpc-async-request
myproc :frobnicate `(:foo "trix")
:success-fn (jsonrpc-lambda (&key bar baz &allow-other-keys)
(message "Server replied back with %s and %s!"
bar baz))
:error-fn (jsonrpc-lambda (&key code message _data)
(message "Sadly, server reports %s: %s"
code message)))
</pre>
</div><div class="_attribution">
<p class="_attribution-p">
Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
<a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/JSONRPC-JSON-object-format.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/JSONRPC-JSON-object-format.html</a>
</p>
</div>
|