Packages
A serialization library implementing the jsonapi.org 1.0 spec suitable for use building JSON APIs in Phoenix and any other Plug based framework or app.
Current section
Files
Jump to
Current section
Files
lib/ja_serializer/formatter/relationship.ex
defimpl JaSerializer.Formatter, for: JaSerializer.Builder.Relationship do
alias JaSerializer.Formatter.Utils
def format(rel) do
json = %{}
|> Utils.put_if_present(:data, JaSerializer.Formatter.format(rel.data))
|> Utils.put_if_present(:links, Utils.array_to_hash(rel.links))
{Utils.format_key(rel.name), json}
end
end