View Source Kiq.Encoder (Kiq v0.7.3)
This module wraps Jason.encode/1
to provide consistent and safe JSON encoding.
Typically this module shouldn't be used outside of Kiq, but the function is documented for reference on how job arguments are encoded.
Summary
Functions
Safely encode terms into JSON, if possible.
Functions
Safely encode terms into JSON, if possible.
Some Elixir/Erlang types can't be represented as JSON. To make encoding as reliable as possible
the encode/1
function attempts to convert incompatible terms into JSON friendly values.
The following sanitization is applied (recursively):
struct
- Converted to a map usingMap.from_struct/1
tuple
— Converted to a listpid
,port
,reference
— Converted to a string using inspect, i.e. "#PID<0.101.0>"