Your "date object" is just an elixir tuple. Posion does not know how to encode Elixir tuples:
iex(1)> Poison.encode({2015, 3, 24}) {:error, {:invalid, {2015, 3, 24}}}
If you first format the date into a string, Posion will have no problem encoding it in JSON:
iex(2)> Poison.encode(:io_lib.format("~4..0B-~2..0B-~2..0B", [2015, 3, 24]) |> List.flatten |> to_string) {:ok, "\"2015-03-24\""}
Hope this helps.
source share