Reputation: 375
The client sends the following JSON:
{"User": {"name": "Jhon", "nationality", "brazilian", "gender": "male"}}
How can I get the JSON and each field and value individually for use in the controller and ecto query?
Automatically translated.
Upvotes: 2
Views: 1005
Reputation: 3727
use elixir poison: https://github.com/devinus/poison
Then use:
Poison.decode!(~s({"User": {"name": "Jhon", "nationality", "brazilian", "gender": "male"}}), as: %User{})
Upvotes: 1
Reputation: 4251
You should be able use conn.params
like so:
conn.params["User"]
, conn.params["User"]["gender"]
, etc.
Upvotes: 0