Commit | Line | Data |
---|---|---|
1ff2619b EB |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2014 David Thompson <davet@gnu.org> | |
3 | ;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org> | |
4 | ;;; | |
5 | ;;; This file is part of GNU Guix. | |
6 | ;;; | |
7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
8 | ;;; under the terms of the GNU General Public License as published by | |
9 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
10 | ;;; your option) any later version. | |
11 | ;;; | |
12 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
13 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | ;;; GNU General Public License for more details. | |
16 | ;;; | |
17 | ;;; You should have received a copy of the GNU General Public License | |
18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
19 | ||
20 | (define-module (guix import json) | |
21 | #:use-module (json) | |
22 | #:use-module (guix utils) | |
23 | #:use-module (guix import utils) | |
24 | #:export (json-fetch)) | |
25 | ||
26 | (define (json-fetch url) | |
27 | "Return an alist representation of the JSON resource URL, or #f on failure." | |
28 | (call-with-temporary-output-file | |
29 | (lambda (temp port) | |
30 | (and (url-fetch url temp) | |
31 | (hash-table->alist | |
32 | (call-with-input-file temp json->scm)))))) |