updated examples for new number api

This commit is contained in:
alisdair sullivan 2010-06-01 02:36:02 -07:00
parent fbf6c30c53
commit c287315ebf
2 changed files with 10 additions and 8 deletions

View file

@ -25,7 +25,7 @@
-author("alisdairsullivan@yahoo.ca"). -author("alisdairsullivan@yahoo.ca").
-export([decode/1, event/2]). -export([decode/1, event/2]).
-export([literal/1, string/1, number/1]). -export([literal/1, string/1, float/1, integer/1]).
%% this is a strict parser, no comments, no naked values and only one key per object. it %% this is a strict parser, no comments, no naked values and only one key per object. it
@ -99,13 +99,15 @@ insert(Key, Val, Dict) ->
end. end.
%% strings, numbers and literals we just return with no post-processing, this is where we %% strings and literals we just return with no post-processing, numbers we convert
%% would deal with them though. %% from strings to integers/floats as appropriate
string(String) -> string(String) ->
String. String.
number(Number) -> integer(Number) ->
Number. list_to_integer(Number).
float(Number) ->
list_to_float(Number).
literal(Literal) -> literal(Literal) ->
Literal. Literal.

View file

@ -88,12 +88,12 @@ jsx_event(end_of_stream, {Acc, _, _, _}) ->
Acc. Acc.
format(number, Number) ->
Number;
format(string, String) -> format(string, String) ->
"\"" ++ String ++ "\""; "\"" ++ String ++ "\"";
format(literal, Literal) -> format(literal, Literal) ->
erlang:atom_to_list(Literal). erlang:atom_to_list(Literal);
format(_, Number) ->
Number;
indent(Indent, Level) -> indent(Indent, Level) ->