From c83cbb13c222bbd9745198994e218480d6607076 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sun, 26 Apr 2020 08:00:28 -0500 Subject: parsing from files example. some exercises --- examples/Tutorial.org | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/examples/Tutorial.org b/examples/Tutorial.org index 5dd3452..f82a872 100644 --- a/examples/Tutorial.org +++ b/examples/Tutorial.org @@ -752,6 +752,60 @@ PZ-JSON> #+END_SRC +Here is how you would parse somejson from a file: + +#+BEGIN_SRC lisp + +PZ-JSON> (with-open-file (file-input "examples/foo.json") + (let ((rp-stream (make-instance 'replay-streams:character-input-replay-stream + :source file-input))) + (parse rp-stream +PZ-JSON> + +#+END_SRC + +For the moment, parsers only work on instances of [[https://github.com/cbeo][replay-streams]]. If +you pass raw text to the =parse= function for its =STREAM= argument, +then you must also pass a =T= into its third optional argument +position. Otherwise the stream is assumed to be a =replay-stream=. + +*** Problems to Puzzle Out + +1. Association Lists may or may not be the most appropriate data + structure for the representation of JSON objects. How could you + change the =