changed api of jsx_parser
This commit is contained in:
parent
8e05d0c1a6
commit
feaef7380c
7 changed files with 18 additions and 14 deletions
|
@ -1,6 +1,6 @@
|
|||
%% The MIT License
|
||||
|
||||
%% Copyright (c) 2010 <alisdairsullivan@yahoo.ca>
|
||||
%% Copyright (c) 2010 Alisdair Sullivan <alisdairsullivan@yahoo.ca>
|
||||
|
||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
%% of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,19 +25,23 @@
|
|||
|
||||
-module(jsx_parser).
|
||||
|
||||
-export([decode/2, event/2]).
|
||||
-export([decode/1, event/2]).
|
||||
-export([literal/1, string/1, number/1]).
|
||||
|
||||
|
||||
%% this is a strict parser, no comments, no naked values and only one key per object. it
|
||||
%% also is not streaming, though it could be modified to parse partial objects/lists.
|
||||
|
||||
decode(JSON, Opts) ->
|
||||
P = jsx:decoder({{jsx_parser, event}, []}, Opts),
|
||||
decode(JSON) ->
|
||||
P = jsx:decoder({{jsx_parser, event}, []}, []),
|
||||
try
|
||||
{Result, Rest} = P(JSON),
|
||||
case jsx:tail_clean(Rest) of
|
||||
true -> Result
|
||||
; _ -> exit(badarg)
|
||||
; _ -> throw(badarg)
|
||||
end
|
||||
catch
|
||||
_:_ -> throw(badarg)
|
||||
end.
|
||||
|
||||
%% erlang representation is dicts for objects and lists for arrays. these are pushed
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%% The MIT License
|
||||
|
||||
%% Copyright (c) 2010 <alisdairsullivan@yahoo.ca>
|
||||
%% Copyright (c) 2010 Alisdair Sullivan <alisdairsullivan@yahoo.ca>
|
||||
|
||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
%% of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%% The MIT License
|
||||
|
||||
%% Copyright (c) 2010 <alisdairsullivan@yahoo.ca>
|
||||
%% Copyright (c) 2010 Alisdair Sullivan <alisdairsullivan@yahoo.ca>
|
||||
|
||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
%% of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%% The MIT License
|
||||
|
||||
%% Copyright (c) 2010 <alisdairsullivan@yahoo.ca>
|
||||
%% Copyright (c) 2010 Alisdair Sullivan <alisdairsullivan@yahoo.ca>
|
||||
|
||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
%% of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%% The MIT License
|
||||
|
||||
%% Copyright (c) 2010 <alisdairsullivan@yahoo.ca>
|
||||
%% Copyright (c) 2010 Alisdair Sullivan <alisdairsullivan@yahoo.ca>
|
||||
|
||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
%% of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%% The MIT License
|
||||
|
||||
%% Copyright (c) 2010 <alisdairsullivan@yahoo.ca>
|
||||
%% Copyright (c) 2010 Alisdair Sullivan <alisdairsullivan@yahoo.ca>
|
||||
|
||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
%% of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%% The MIT License
|
||||
|
||||
%% Copyright (c) 2010 <alisdairsullivan@yahoo.ca>
|
||||
%% Copyright (c) 2010 Alisdair Sullivan <alisdairsullivan@yahoo.ca>
|
||||
|
||||
%% Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
%% of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue