chickadee » json-abnf » bi-text

bi-textprocedure

The bidirectional counterpart of a whole JSON document: like bi-value, but also accepts optional surrounding whitespace, matching RFC 8259's rule for a complete JSON text (ws value ws). printer is bp-print applied to bi-text.

(import json-abnf abnf-lens)

;; bp-parse returns (list (list matched-value) remaining-stream);
;; (car (car ...)) unwraps it to the matched value.
(car (car (bp-parse bi-text "[1,2,3]" (lambda (s) (error "parse failed" s)))))
;; => #(1 2 3)

(bp-print bi-text (vector 1 2 3))
;; => "[1,2,3]"