json-stream-read should validate json too Duy Nguyen (21 Jan 2020 09:15 UTC)
Re: json-stream-read should validate json too Amirouche Boubekki (21 Jan 2020 10:47 UTC)
Re: json-stream-read should validate json too Duy Nguyen (21 Jan 2020 12:44 UTC)
Re: json-stream-read should validate json too Amirouche Boubekki (21 Jan 2020 13:46 UTC)
Re: json-stream-read should validate json too Duy Nguyen (23 Jan 2020 09:11 UTC)
Re: json-stream-read should validate json too Amirouche Boubekki (23 Jan 2020 19:12 UTC)
Re: json-stream-read should validate json too Amirouche Boubekki (23 Jan 2020 19:24 UTC)
Re: json-stream-read should validate json too Amirouche Boubekki (23 Jan 2020 19:16 UTC)

json-stream-read should validate json too Duy Nguyen 21 Jan 2020 09:14 UTC

I feel that without validation it's more like a tokenizer than an
actual parser. Anybody who wants to use it will have to implement
duplicated validation logic (and could get it wrong if they're not
careful). Is it possible to adjust the interface to move validation
back inside json-stream-read (or at least an option to include
validation)?

Something like srfi-171 "transducers" could help make a
container-independent json stream parser. The exact data type for
arrays and objects are controlled by transducers (though I haven't
really worked it out yet). Transducers seem a good fit for this to
potentially create large data structures with minimum intermediate
copies.

Alternatively maybe we can wrap user-provided 'proc' in our own proc
that does validation on top, something like a stripped down version of
%json-read that does nothing but validate? For example,
make-json-validator takes a proc and returns a new proc also performs
validation.
--
Duy