daggaz / json-stream

Simple streaming JSON parser and encoder.
MIT License
122 stars 18 forks source link

Support for binary mode files #10

Closed daggaz closed 2 years ago

daggaz commented 2 years ago

json_stream.load(fp) does not handle fps that produce bytes (such as those returned from urllib.request.urlopen()).

This issue was raised by @yyellin in #9.

See the discussion there for more details.

daggaz commented 2 years ago

The changes in PR test the input "file" to see if it returns bytes or str and wraps any byte-file in an io.TextIOWrapper. The encoding is used by the TextIOWrapper is guessed from: