8000 Elixir-compatible null handling · Issue #64 · davisp/jiffy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content < 8000 react-partial partial-name="keyboard-shortcuts-dialog" data-ssr="false" data-attempted-ssr="false" data-react-profiling="false" >
Elixir-compatible null handling #64
Closed
@ammmir

Description

@ammmir

It would be nice for jiffy to support Elixir, namely the way null/nil is handled. Currently it's not ideal:

iex(1)> :jiffy.encode %{results: nil}                        
"{\"results\":\"nil\"}"
iex(2)> :jiffy.decode "{\"results\":null}", [:return_maps]   
%{"results" => :null}

When encoding, a nil atom should be turned into a JSON null, not a "nil" string as in the current implementation. Likewise, decoding a JSON null should result in a nil atom, not null. I'm not sure about the best way to handle this, but perhaps some option like use_nil_for_null could be added so jiffy can be painlessly used from Elixir :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0