JSON that does not silently round money.
The payments surface returns monetary fields as JSON numbers, frozen for
NowPayments compatibility. Decoding them into floats loses digits
(0.123456789012345678 becomes 0.12345678901234568) with no error, and
Elixir's standard library has no JSON decoder at all before 1.18.
So this module parses by hand and keeps every number as the exact text between two separators, and it validates a literal against a strict grammar before it emits one unquoted.
Summary
Functions
Whether a string is a plain JSON number literal.
Decode a JSON object, keeping every number as its exact source text.
Encode a flat payload, emitting the named fields as JSON numbers with every supplied digit.
Whether a string is a decimal literal greater than zero.
Functions
Whether a string is a plain JSON number literal.
Decode a JSON object, keeping every number as its exact source text.
Raises Payzum.Errors.Validation when the payload is not a JSON object.
Encode a flat payload, emitting the named fields as JSON numbers with every supplied digit.
Raises Payzum.Errors.Validation when a value cannot be emitted safely.
Whether a string is a decimal literal greater than zero.
Decided on the mantissa, so 0e10 is not mistaken for a positive amount.