Closed Licenser closed 7 years ago
jsone
doesn't have to necessarily conform to matching encoded and decoded data requirement for every option and data combination. undefined_as_null
is a good example of it.
1> X = [null, undefined], jsone:encode(X, [undefined_as_null]).
<<"[null,null]">>
There is not a way you could generaly decode [null,null]
JSON to match X = [null, undefined]
.
Yes mixed decoding can't work. However, it's not entirely unreasonable to approach it from a way of "if you use undefined you should stick with undefined" no one will expect an en/decoder to magically know which null
was what before. Expecting to keep the same value for en-decoding as long as that information is available seems reasonable.
With
undefined_as_null
there is a situation where the encoded and decoded data does not match at this point asnull
is always decoded asnull
. It would be nice if the decode tookundefined_as_null
as an option as well to mirror the behavior of the encoder.