Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONTestSuite test results #49

Open
l1bbcsg opened this issue May 4, 2018 · 4 comments
Open

JSONTestSuite test results #49

l1bbcsg opened this issue May 4, 2018 · 4 comments

Comments

@l1bbcsg
Copy link

l1bbcsg commented May 4, 2018

There's this Parsing JSON is a Minefield article which details various issues (mostly in edge cases) across different JSON parsers.

Its author produced a test suit to test various implementations. I've run this test suit against Clarinet (on node 9.6.1), results compared to native JSON.parse are below (successful tests not shown).

Generally, I think the results are good with Clarinet being pretty close to native implementation and never failing too hard. But there are two things it still does wrong: It does not fail on some wrong inputs and fails on legitimate results consisting of one literal (i.e. null). The former is pretty minor I think, while the latter may lead to compatibility issues.

I'm raising this issue more for the purposes of discussion. What do you think, should those be addressed?

Results screenshot

image

Legend

image

Snippet I used to run Clarinet (derived from their JSON.parse):

var fs = require('fs');
var path = process.argv[2];
var clarinet = require('clarinet');
var parser = clarinet.parser();

try {
	var data = fs.readFileSync(path, 'utf-8');

	parser.onerror = function(e) {
		throw e;
	}
	parser.write(data).close();
	
} catch (e) {
	console.log("--", e.message)
	process.exit(1);
}

process.exit(0);

Note that at the time of writing the test runner has a really weird bug preventing it from running which isn't hard to patch out though.

@dscape
Copy link
Owner

dscape commented May 17, 2018

This is amazing, thank you so much for this contribution!! Unfortunately I stopped coding a while back and don't find myself with the time to do the corrections.

We need to find a new maintainer to the project to make these changes, and I'm unsure if the module is used enough for this to be a good idea!

@evan-king
Copy link
Collaborator

Apologies from me, I saw this issue but responding to it slipped through the cracks. I somewhat expected @dscape's response to strongly favor backwards compatibility (including permissive handling of non-compliant input), but if that's not the case I'll be happy to assist.

My own availability is a bit up in the air currently but may include some time to implement corrections. Either way however, I can definitely accept patches for them.

@dscape
Copy link
Owner

dscape commented May 17, 2018 via email

@corno
Copy link

corno commented Feb 4, 2020

For anyone interested: I forked clarinet into 'bass-clarinet' and that one complies to the full JSONTestSuite testset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants