library of babel: added json function for accessing local or remote json objects

A quick example of accessing remote json data from Babel code blocks.

  Evaluate the following to see a listing of parks in DC by ward.

  #+source: dc-parks
  #+begin_src emacs-lisp :var keys='(ward address) :var data=json(url="http://ogdi.cloudapp.net/v1/dc/RecreationParks?format=json")
    (append
     (list keys 'hline)
     (mapcar
      (lambda (lis) (mapcar (lambda (key) (cdr (assoc key lis))) keys))
      (cdr (car data))))
  #+end_src
This commit is contained in:
Eric Schulte 2010-06-27 15:50:07 -07:00
parent f63d977c8b
commit 517837b3a1
1 changed files with 20 additions and 17 deletions

View File

@ -1,22 +1,6 @@
#+title: The Library of Babel
#+SEQ_TODO: TODO PROPOSED | DONE DEFERRED REJECTED
#+OPTIONS: H:3 num:nil toc:2 \n:nil @:t ::t |:t ^:t -:t f:t *:t TeX:t LaTeX:t skip:nil d:(HIDE) tags:not-in-toc
#+author: Org-mode People
#+STARTUP: odd hideblocks
#+STYLE: <style type="text/css">#outline-container-1 { clear:both; }</style>
#+begin_html
<div id="logo" style="float: left; text-align: center; max-width: 340px; font-size: 8pt; margin-left: 1em;">
<p>
<img src="../../images/babel/library-of-babel.png" alt="Library of Babel"/>
<div id="attr">
The Library of Babel, by Pierre Clayette
<p>
<a href="http://downlode.org/Etext/library_of_babel.html">Full text of the Borges short story</a>
</p>
</div>
</p>
</div>
#+end_html
* Introduction
The Library of Babel is an extensible collection of ready-made and
@ -69,6 +53,25 @@ as a table in traditional Org-mode table syntax.
nil
#+end_src
** remote files
Read local or remote file in [[http://www.json.org/][json]] format into emacs-lisp objects.
#+srcname: json
#+begin_src emacs-lisp :var file='() :var url='()
(require 'json)
(cond
(file
(with-temp-filebuffer file
(goto-char (point-min))
(json-read)))
(url
(require 'w3m)
(with-temp-buffer
(w3m-retrieve url)
(goto-char (point-min))
(json-read))))
#+end_src
* Plotting code
** R