Ecto => Json (Api)
Convert an ecto schema into json.
EctoJsonapi is tool for dealing with JsonAPI and Ecto schemas:
EctoJsonApi.Dump/1
Converts elixir maps Ecto schemas.EctoJsonApi.Dump/1
Converts JsonApi v1.0 syntax into Ecto schemas.EctoJsonApi.Load/2
Converts Ecto schemas into elixir maps structured like JsonApi v1.0.
** To be completed ** please bug: https://github.com/mrmicahcooper
user = %User{
id: 456,
name: "Micah Cooper",
email: "[email protected]"
}
data = {:ok,
%{
user: user,
}
}
json = EctoJsonapi.Load.load(data)
assert get_in(json, ["data", "attributes", "content"])
For a more indepth example checkout the test suite
Micah really likes this project and is looking for contributors.
Are you using the project? Feel free to leave an Issue to show your support: issue