From d9fc9074cbf4064b855801589a03159256a49bc8 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 17 Aug 2025 03:21:08 +0100 Subject: reader: Add read-json-file. read-json-file is a wrapper around call-with-input-file and json->scm. It raises the relevant exceptions when it fails. --- ravanan/reader.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ravanan/reader.scm b/ravanan/reader.scm index 731ed92..8b8ac50 100644 --- a/ravanan/reader.scm +++ b/ravanan/reader.scm @@ -17,6 +17,8 @@ ;;; along with ravanan. If not, see . (define-module (ravanan reader) + #:use-module (rnrs conditions) + #:use-module (rnrs exceptions) #:use-module (rnrs io ports) #:use-module (srfi srfi-26) #:use-module (ice-9 filesystem) @@ -310,3 +312,12 @@ array of array of @code{File}s, etc. Else, return @code{#f}" val (string->number val))) (else val))) + +(define (read-json-file file) + "Read JSON @var{file} and return scheme tree." + (guard (c (else + (raise-exception + (condition (make-who-condition 'read-json-file) + c)))) + (call-with-input-file file + json->scm))) -- cgit 1.4.1