String to term

Mark Scandariato mscandar@REDACTED
Wed Apr 27 15:29:57 CEST 2005


Inswitch Solutions - Erlang Evaluation wrote:
> Hi,
> 
> Does someone know if there is an easy way to convert a string to an Erlang
> term?
> example:
> "{1,2,[hello]}" ---- converted to ----->  {1,2,[hello]}
> 
> 
> thanks in advance,
> Eduardo Figoli
> INSwitch Solutions
> 
> 


1> {ok, Tokens, _} = erl_scan:string("{1,2,[hello]}.").
{ok,[{'{',1},
      {integer,1,1},
      {',',1},
      {integer,1,2},
      {',',1},
      {'[',1},
      {atom,1,hello},
      {']',1},
      {'}',1},
      {dot,1}],
     1}
2> {ok, Term} = erl_parse:parse_term(Tokens).
{ok,{1,2,[hello]}}
3>


Mark.



More information about the erlang-questions mailing list