Open ccqpein opened 3 years ago
code-char doesn't seem right, though.
I think this issue should be closed. in-memory-stream
is explicitly a binary stream with no support for characters.
To get characters, a flexi-stream needs to be used on top of the in-memory-stream:
(flexi-streams:with-input-from-sequence (mem input-sequence)
(let ((text (flexi-streams:make-flexi-stream mem :external-format :utf-8)))
(yason:parse text)))
Hi guys, I am trying to run JSON parser
(yason:parse)
withflexi-streams:in-memory-stream
directly, because(yason:parse)
can accept string steam input directly.Then SBCL gives me the error when I did it. After checking the code of yason::parse and the error message, I found there are two generic functions of SBCL that needed to be implemented:
SB-GRAY:STREAM-READ-CHAR
andSB-GRAY:STREAM-PEEK-CHAR
So I tried to implement by code:
Then
yason:parse
works fine withflexi-streams:in-memory-stream
(at least now).Do you guys trying to implement
peek-char
forflexi-streams:in-memory-stream
? My code just work, I am not sure I met all hidden details offlexi-streams:in-memory-stream
. It would be nice ifflexi-stream
haspeek-char
natively.Thanks