Consumes nBytes
bytes from the stream, interprets the bytes as a utf-8 string and the string as a valid JSON object.
Equations
- h.readJson nBytes = do let bytes ← h.read (USize.ofNat nBytes) match String.fromUTF8? bytes with | some s => IO.ofExcept (Lean.Json.parse s) | x => throw (IO.userError "invalid UTF-8")
Instances For
Equations
- h.writeJson j = do h.putStr j.compress h.flush