modified jsx_parser to reject bare json values, fixed typo

This commit is contained in:
alisdair sullivan 2010-05-31 02:36:16 -07:00
parent 2cf20cf809
commit 5f5be51365

View file

@ -37,7 +37,7 @@ decode(JSON) ->
{incomplete, _} ->
{error, badjson}
; {error, badjson} ->
{error, badjosn}
{error, badjson}
; {Result, _} ->
Result
end.
@ -72,6 +72,11 @@ event(end_array, [Array]) ->
event({key, Key}, [Object|Stack]) ->
[{key, Key}] ++ [Object] ++ Stack;
%% reject values that aren't wrapped by an array or object
event({_Type, _Value}, []) ->
erlang:error(badjson);
%% this is kind of a dirty hack, but erlang will interpret atoms when applied to (Args)
%% as a function. so naming our formatting functions string, number and literal will
%% allow the following shortcut