[erlang-questions] New project: ZJ - A tiny JSON encoder/decoder

zxq9@REDACTED zxq9@REDACTED
Wed Jun 27 09:21:53 CEST 2018


On 2018年6月27日水曜日 8時05分59秒 JST Roger Lipscombe wrote:
> If we were dealing with records, I'd argue that 'undefined' should map
> to *omitted*, but we're dealing with maps, so... (shrugs).
> 
> Incidentally:
> - https://github.com/davisp/jiffy/issues/4
> - https://github.com/davisp/jiffy/issues/27
> - https://github.com/talentdeficit/jsx/issues/18
> 
> On 27 June 2018 at 07:06, Max Lapshin <max.lapshin@REDACTED> wrote:
> > I also think that  erlang undefined should be converted to  json  null and
> > back.


Indeed. On reflection the argument for translating the semantic VS merely
passing along the label that conveys it has won me over.

I pulled the v1.0.0 tag that I had *just* pushed and reworked it.

ZJ's type mapping: https://gitlab.com/zxq9/zj#type-mapping

Erlang -> JSON
- true      -> true
- false     -> false
- undefined -> null
- Atom      -> String

JSON -> Erlang
- true  -> true
- false -> false
- null  -> undefined

Note that non-special atoms map to strings, and that includes 'null' now
mapping to "null".

Thanks, fellas.

-Craig



More information about the erlang-questions mailing list