Closed neel-desh closed 8 months ago
In general overriding protocol implementations is not supported in Elixir and is largely accidental how it would work. For Jason in particular, it does not use the protocol for encoding core data types to avoid the overhead of the protocol dispatch in the regular case. This means there is generally no way to override how values are encoded, other than:
Jason.Fragment.new/1
as raw JSON data to be spliced when encoding
Hi, I just wanted to know how do I change the behavior of Float in Jason.encode!()
By default
Jason.encode!(1000.0)
returns"1.0e3"
I wantJason.encode!(1000.0)
to return"1000.0"
I tried to make this change.
And I was expecting it to work! but sadly it did not. Can someone please guide me in the right direction.
Thanks