Thoas - Elixir's Jason JSON library converted to Erlang

Guess could be a compromise.

But then I would expect that thoas:encode/1 also never throws, but only thoas_throwing:encode/1 does. I see that currently thoas:encode/1 has at least one explicit exception thoas/src/thoas_encode.erl at 523c6831aed68b603d427d505d1dd571ddd021da · lpil/thoas · GitHub and I guess a lot of implicit ones (a-la function_clause)

2> thoas:encode(#{"hello" => <<"world">>}).
<<"{\"hello\":\"world\"}">>
3> thoas:encode(#{"привет" => <<"world">>}).
** exception error: bad argument
     in function  list_to_binary/1
        called as list_to_binary([1087,1088,1080,1074,1077,1090])
4> thoas:encode(#{"hello" => make_ref()}). % yes, we are not obeying type specification here     
** exception error: no function clause matching thoas_encode:value(#Ref<0.1085671603.2705588226.206231>,
                                                                   #Fun<thoas_encode.0.100822224>) (/home/seriy/workspace/thoas/src/thoas_encode.erl, line 1717)
2 Likes