JViewer (JViewer v0.1.5) View Source
JViewer is an excellent way to declaratively represent elixir data in a JSON encodable format.
Link to this section Summary
Functions
Represents data in a JSON encodable format according to schema.
Link to this section Types
Specs
schema() :: JViewer.Types.Object.t()
Link to this section Functions
Specs
Specs
Specs
Specs
Specs
Specs
Represents data in a JSON encodable format according to schema.
If data cannot be represented, an exception is thrown.
Example
iex> import JViewer
...>
iex> schema =
iex> object(
iex> fields: [
iex> field(
iex> key: "id",
iex> type: number()
iex> ),
iex> field(
iex> key: "title",
iex> type: string()
iex> )
iex> ]
iex> )
...>
iex> data = %{
iex> id: 1,
iex> info: "I ate bread for breakfast",
iex> title: "Notes"
iex> }
...>
iex> represent(data, schema)
%{
"id" => 1,
"title" => "Notes"
}