What is most correct way to open, read and parse JSON file with poison?
For example if we have example.json file in root of some project.
Is it?
def get_json(filename) do
# ....
end
P.S Sorry for question i’m in Elixir
What is most correct way to open, read and parse JSON file with poison?
For example if we have example.json file in root of some project.
Is it?
def get_json(filename) do
# ....
end
P.S Sorry for question i’m in Elixir
I’m not sure if it’s the correct way, but I would do something like this
defmodule Test do
def get_json(filename) do
with {:ok, body} <- File.read(filename),
{:ok, json} <- Poison.decode(body), do: {:ok, json}
end
end
Me too, but looks nice. Thank you!