I don't know if its the best way but I use this:
Instead of
{json, [{error,(ErrorList)}]}
I use:
{json, [{error,list_to_binary(ErrorList)}]}
This also seems to work:
{json, [{error,io_lib:write_string(ErrorList)}]}
I think the list_to_binary method cannot convert unicode characters
(http://www.erlang.org/doc/man/unicode.html) so for that case you could
need to use
{json, [{error,unicode:characters_to_binary(ErrorList)}]}
Someone please correct me if I am wrong.
Thanks,
Jitin
On Monday, 20 October 2014 12:12:55 UTC+5:30, Alex V wrote:
>
>
>
> Hi everyone.
>
> Saw similar, but unanswered questions.
>
> When returning json from a controller, the browser often gets arrays
> instead of strings (even from tutorial examples, "greeting-N" always
> becomes an array) and vice versa. How do you control this behavior?
>
--
You received this message because you are subscribed to the Google Groups
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit
https://groups.google.com/d/msgid/chicagoboss/00c17940-3c02-4f86-8b9a-bb16b4d52039%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.