You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I currently am working on encoding an elixir map to JSON and noticed some things that I was confused by.
First I noticed that where I put True in my original Map gets encoded to Elixir.True. Why is that and how do I change that?
Second, the Content part of my map gets encoded to JSON with triple escapes. Is this expected behavior and is there a way to change that?
Any help you can offer would be greatly appreciated.
(Sorry if you read this before I made my edits. My original post came off sounding terse and without context. I had outlined what I wanted to ask and accidentally hit submit)
True in Elixir is an alias, or a module name in other words, when they module names are printed as atoms they get Elixir. prepended. You were probably meaning to use the lower case true instead, which is the boolean true value.
When elixir strings are inspected " gets escaped, " inside strings in json are also escaped. If you print your JSON string with IO.puts(json) instead of IO.inspect(json) it may look as you expect.
Hello,
I currently am working on encoding an elixir map to JSON and noticed some things that I was confused by.
First I noticed that where I put
True
in my original Map gets encoded toElixir.True
. Why is that and how do I change that?Second, the
Content
part of my map gets encoded to JSON with triple escapes. Is this expected behavior and is there a way to change that?Any help you can offer would be greatly appreciated.
(Sorry if you read this before I made my edits. My original post came off sounding terse and without context. I had outlined what I wanted to ask and accidentally hit submit)
Here is the original Elixir Map I'm encoding:
And here is the resulting JSON:
The text was updated successfully, but these errors were encountered: