[erlang-questions] New project: ZJ - A tiny JSON encoder/decoder
Thu Jun 28 14:49:45 CEST 2018
On 2018年6月28日木曜日 19時16分42秒 JST zxq9@REDACTED wrote:
> On 2018年6月28日木曜日 17時50分04秒 JST zxq9@REDACTED wrote:
> > On 2018年6月28日木曜日 10時44分13秒 JST you wrote:
> > > For testing JSON parsers/encoders I recommend https://github.com/nst/JSONTestSuite
> > Thanks, Michał!
> > Over the weekend I might hook the two together.
> > If it isn't too complicated I might drop a script for this in there.
> Ran through the test set in the shell just to get some idea, and there
> are a few cases that do need to be fixed -- all are weird (but legal) or
> malformed (and some dangerous) number representations.
> I'll probably put a test function in there that does what I just did
> in the shell. Including the test set into the repo is a little :-/
> Including ZJ into the JSON test project might be a better approach.
> Once the handful of failing cases are sorted, I don't expect to be
> patching ZJ much.
All cases that MUST work according to the JSON Test Suite project now do.
A handful of cases that SHOULD NOT work do anyway (trailing commas, for
example) -- but are mostly of no consequence.
A handful of cases that MAY work do, but most do not.
Several cases that MAY or SHOULD NOT work return clean or truncated
results in decode/1 but return an error in binary_decode/1 due to the
way unicode:characters_to_list/1 and unicode:characters_to_binary/1
One test case crashes: n_structure_open_array_object.json
It is not supposed to work and and crashes many parsers -- this one
included. The attempted allocation of tens of thousands of nested maps
OOMs the runtime. ZJ does not define (or track) object/array depth.
I might implement depth tracking later just for safety.
Results are here:
I don't have time to formalize all this, but I suspect that the JSON
definition and test cases won't change much in the future.
More information about the erlang-questions