Add encoder option to turn off default encoding of atoms into unicode strings #55

wants to merge 2 commits into


None yet

2 participants


The option encode_atoms was added to #encoder{} in mochijson2. Setting this option to false will cause json_encode to fail when encountering an atom other than true, false, null. This will allow custom encoders to handle them.

Added this because I wanted to encode 'undefined' as <<"null">> using a custom encoder, but the default encoding would process them before the custom encoder was invoked.

onkel-dirtus added some commits Aug 11, 2011
@onkel-dirtus onkel-dirtus add encode_atoms option
Provide option to turn off default behavior of encoding atoms to
@onkel-dirtus onkel-dirtus break out json_encode for atoms into its own function head 1d855b6
etrepum commented Oct 6, 2011

I think it would be better to have an option that encodes undefined to <<"null">> instead of having to set this option and provide the encoder to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment