SafeJson.Serialize protocol (fnord v0.9.29)

View Source

Protocol for converting structs to JSON-safe plain maps. Implement this instead of @derive {Jason.Encoder, ...} to keep the JSON backend as an internal detail of SafeJson.

Summary

Types

t()

All the types that implement this protocol.

Functions

Returns a plain map (or other JSON-encodable term) representing the struct. The returned value will be recursively sanitized by SafeJson before encoding.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

for_json(value)

@spec for_json(t()) :: term()

Returns a plain map (or other JSON-encodable term) representing the struct. The returned value will be recursively sanitized by SafeJson before encoding.