Open yangcheng opened 11 months ago
Encoder or decoder is mostly used for streaming or some specific configurations, such as decoder with UseNumber
, or encoder with SortKeys
. And there are no benefits to reusing an encoder or decoder. So recommended not to use a shared encoder or decoder.
good to know that, I was about to use encoder for streaming io as mentioned in https://github.com/bytedance/sonic#streaming-io , no specific configuration, just http write response. is it recommended to simplely use Marshal
?
The reason I am asking is I noticed very similar performance os sonic encoder vs json encoder in my test and I am curious if I did something wrong
good to know that, I was about to use encoder for streaming io as mentioned in https://github.com/bytedance/sonic#streaming-io , no specific configuration, just http write response. is it recommended to simplely use
Marshal
?
yes, if not in streaming scenes or specific configuration, just use Marshal
It's unclear from documentation what's the best practice to use encoder and decoder.
Should I keep a global encoder ? is the object thread-safe?
Thanks