Tempo.SQL.JSON (Tempo SQL v0.1.0)

View Source

Shim module that adapts Erlang's built-in :json (OTP 27+) to Postgrex's expected JSON-library interface.

Postgrex's jsonb extension calls library.encode_to_iodata!/1 and library.decode!/1 (the shapes Jason exposes). Erlang's :json exposes encode/2 and decode/3, so this module bridges the two. It also configures nil ↔ JSON null translation in both directions, sparing application code from the :null atom the raw :json module returns.

Use from Postgrex

Postgrex.Types.define(MyApp.PostgresTypes, [], json: Tempo.SQL.JSON)

Summary

Functions

Postgrex-compatible decoder.

Postgrex-compatible encoder. Returns iodata.

Functions

decode!(binary)

Postgrex-compatible decoder.

encode_to_iodata!(term)

Postgrex-compatible encoder. Returns iodata.