Conduit v0.1.1 Conduit.ContentType.JSON

Handles converting a message body to and from JSON.

Summary

Functions

Formats the message body to json and sets the content type

Parses the message body from json and sets the content type

Functions

format(message, opts)

Formats the message body to json and sets the content type.

Examples

iex> import Conduit.Message
iex> message =
iex>   %Conduit.Message{}
iex>   |> put_body(%{})
iex>   |> Conduit.ContentType.JSON.format([])
iex> message.body
"{}"
iex> get_meta(message, :content_type)
"application/json"
parse(message, opts)

Parses the message body from json and sets the content type.

Examples

iex> import Conduit.Message
iex> message =
iex>   %Conduit.Message{}
iex>   |> put_body("{}")
iex>   |> Conduit.ContentType.JSON.parse([])
iex> message.body
%{}
iex> get_meta(message, :content_type)
"application/json"