AshJason.Resource
View SourceAsh.Resource extension for implementing Jason.Encoder protocol.
jason
Configuration for Jason encoder implementation.
Nested DSLs
Options
| Name | Type | Default | Docs |
|---|---|---|---|
pick | list(atom) | %{optional(:private?) => boolean, optional(:sensitive?) => boolean, optional(:include) => list(atom), optional(:exclude) => list(atom)} | Keys to pick from a record into a result. Accepts an explicit names list or a behaviour configuration map. |
jason.compact
compact configA step to omit fields with unwanted values (nil, for example).
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
config | boolean | {:only, list(atom)} | {:except, list(atom)} | %{optional(:values) => list(any), optional(:fields) => {:only, list(atom)} | {:except, list(atom)}} | Accepts true to remove any field with nil, a tagged only/except tuple to specify targeted fields or a map to configure which value or fields to work on. |
jason.merge
merge valuesA step to merge fixed values into a result.
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
values | list({any, any}) | %{optional(any) => any} | Values to merge into a result. Accepts a map or a tuples list. |
jason.rename
rename renamesA step to rename keys in a result.
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
renames | list({any, any}) | %{optional(any) => any} | (any -> any) | A mapping for renaming keys in a result. Accepts a map, a tuples list or a function. |
jason.order
order sortA step to reorder keys in a result.
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
sort | boolean | (list(any) -> list(any)) | list(any) | An order to apply to keys in json. Accepts a boolean, a sort function or a list of keys in a desired order. |
jason.customize
customize funA step to arbitrary customize a result.
Arguments
| Name | Type | Default | Docs |
|---|---|---|---|
fun | (list({any, any}), map -> list({any, any})) | A function to customize a result with. Receives a result and a resource record. |