sjson icon indicating copy to clipboard operation
sjson copied to clipboard

Mismatched Encoding / Decoding of Byte Values

Open jshlbrd opened this issue 3 years ago • 0 comments

great project, thanks for your contribution to open source!

i'm consistently experiencing some unusual behavior when setting byte values (the impacted code is here and here): when byte values are set, they are converted to a string and then (by default) encoded using the standard library's json.Marshal function, but (for reasons i don't understand) it appears that json.Unmarshal does not decode the value back to the original byte value. here's an example showing how SJSON's behavior mimics the behavior of the standard library, plus a "working example" using strconv to get the original bytes.

as an aside, was it a design decision for SJSON to not encode bytes as a base64 encoded string? that is how the standard library works and it would also solve the problem of consistently decoding back to the original value.

thanks!

jshlbrd avatar Jul 10 '22 21:07 jshlbrd