sonic-rs
sonic-rs copied to clipboard
Support from_reader() like serde_json::from_reader()
Is your feature request related to a problem? Please describe.
Any function to deserialize from a TcpStream or File?
there are no existing functions as from_reader
in #38, welcome to PR for it
@liuq19 I think there are two ways:
- Call
io::Read::read_to_end
to save data in a buffer, and callfrom_slice
. This is a simple way that references https://github.com/simd-lite/simd-json/blob/dd7fc44f5526e3e2abe0ebba53bc1faed501a128/src/serde.rs#L143C8-L143C19. - Adapt
Reader
trait forio::Read
. This could be complex. We have to redesignReader
trait API and do refactor.serde
do this way since it deserializes json char by char, which consists of the feature ofio::Read
. But we may get better performance.
thanks, I prefer the first method, could you try it?