1

I'm trying to print a list of records from mnesia.

Users = boss_db:find(users, []),
lists:foreach(fun(X) ->         
[{_,Email,_,_,_,_,AccessToken}] = X,
io:format("Email : ~w~n",[Email]),
io:format("AccessToken : ~w~n",[AccessToken]), end, [Users]).

However I'm getting:

Email : [117,115,101,..,..,.,..]

Similarly for AccessToken.

What am I missing? Any pointer would be really appreciated.

mpm
  • 3,534
  • 23
  • 33
raich
  • 127
  • 1
  • 8

1 Answers1

1

You didn't choose the right format: ~w is used to print as erlang term, ~s is used for string, ~p for pretty print, it tries to find the best way to print . See doc at http://www.erlang.org/doc/man/io.html#format-3

1> L = "Hello".
"Hello"
2> io:format("~w~n",[L]).
[72,101,108,108,111]
ok
3> io:format("~p~n",[L]).
"Hello"
ok
4> io:format("~s~n",[L]).
Hello
ok
5> L1 = [1,2,3,4,5].     
[1,2,3,4,5]
6> io:format("~w~n",[L1]).
[1,2,3,4,5]
ok
7> io:format("~p~n",[L1]).
[1,2,3,4,5]
ok
8> io:format("~s~n",[L1]).
^A^B^C^D^E
ok
9> 
Pascal
  • 13,977
  • 2
  • 24
  • 32