ja_serializer v0.18.1 JaSerializer View Source
A library for generating JSON-API.org spec compliant JSON.
JaSerializer has three main public components:
JaSerializer.Serializer- A Behaviour defining how a particular object is serialized. Provides default empty callbacks and ability to override.JaSerializer.DSL- A macro based DSL that sits on top of the Behaviour for quick, clean, and easy definition of serializers.JaSerializer.PhoenixView- Provides render functions for a view to take advantage of the serialization interface.
When used the JaSerializer module includes the Behaviour and DSL by default.
The DSL can be opted out of by passing dsl: false, eg:
defmodule MyApp.PostSerializer do
use JaSerializer, dsl: false
# ...
endIf using JaSerializer with Phoenix, your normal entry point is
JaSerializer.PhoenixView, eg:
defmodule MyApp.PostView do
use MyApp.Web, :view
use JaSerializer.PhoenixView
# ...
end
Link to this section Summary
Functions
Main serialization method.
Link to this section Functions
Main serialization method.
Accepts a module implementing the JaSerializer.Serializer behaviour, data, the conn and opts and returns a map ready for json encoding.