square/moshi

Parsing json reading from java.io.Reader object.

DikenMaharjan opened this issue · 3 comments

Is there plan to include a function in JsonAdapter that accepts java.io.Reader object for parsing json?

We would not. If there was anything for this, it would exist at the okio layer and allow you to constructed a BufferedSource from a Reader

I was wondering what if the BufferedSource is UTF-16 encoded. The JsonReader.of(BufferedSource source) is expecting UTF-8 encoded stream. Should I be converting UTF-16 encoded stream to UTF-8 encoding?

Yes. Moshi only operates on UTF-8 encoded bytes. You can write a decorating Source that does the conversion on-the-fly, or do it as one large operation depending on the size of your data.