Closed bkolodziej closed 7 years ago
Indeed, as a null value, undefined
is the de facto standard in Erlang. But there is no enforceable to use undefined
as the only nullable value.
So, I prefer provides this functionality as an option like https://github.com/sile/jsone/pull/22.
This issue was solved at https://github.com/sile/jsone/pull/22.
undefined
is a default value for eg. not set fields in records.undefined
is accepted standard fornull
in Erlang.Encoding
undefined
as text"undefined"
is problematic when converting mnesia records to maps or list of tuples. This behaviour requires additional steps (or redefining all records to setnull
as default value instead ofundefined
).My proposition is to add following line to
jsone_encode
module:value(undefined, Nexts, Buf, Opt) -> next(Nexts, <<Buf/binary, "null">>, Opt);
...or probably better option at this point:
value(undefined, Nexts, Buf, Opt = ?OPT{undefined_as_null = true}) -> next(Nexts, <<Buf/binary, "null">>, Opt);
and extend
encode_opt_v2
: