Hi all
I have a function with following spec definition:
@spec parse_json_struct(String.t) :: %{firstname: String.t, lastname: String.t}
def parse_json_struct(value) do
map = Poison.Parser.parse!(value)
map = map["d"]
%{firstname: Map.fetch(map, "Firstname"), lastname: Map.fetch(map, "Lastname")}
end
The dialyzer complain:
lib/auth/user_login.ex:42: Invalid type specification for function 'Elixir.SapOdataService.Auth.UserLogin':parse_json_struct/1. The success typing is (binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])) -> #{'firstname':='error' | {'ok',_}, 'lastname':='error' | {'ok',_}}
What is wrong?
Thanks