Closed kuenishi closed 11 years ago
Add option to encoder/2, which enables ignoring null or undefined atoms to make small output json.
encoder/2
null
undefined
Encoder = jsonx:encoder([{r0, record_info(r0)}], [{ignore, [null]}]), <<"{}">> = Encoder({r0, null, null, null}).
Of course this encoding is irreversible, but sometimes size matters - the record can be rebuilt if json schema is known, or record name is included inside the object.
[{<<"record_name">>, <<"r0">>}] = jsonx:decode(<<"{\"record_name\":\"r0\"}">>), {r0, null, null, null} = rebuild_r0([{<<"record_name">>, <<"r0">>}], null).
Thank you!
Add option to
encoder/2
, which enables ignoringnull
orundefined
atoms to make small output json.Of course this encoding is irreversible, but sometimes size matters - the record can be rebuilt if json schema is known, or record name is included inside the object.