Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a defined set of JSON parser tests that validate the majority of edge cases?

Tags:

I'm researching some JSON parsers, but some are home-grown. Is there a validation test that can be run against a json parser which verifies that the parser is "valid" and serializes/deserializes JSON string properly?

like image 238
Dave Viner Avatar asked Sep 27 '10 16:09

Dave Viner


People also ask

How to validate JSON data?

The simplest way to check if JSON is valid is to load the JSON into a JObject or JArray and then use the IsValid(JToken, JsonSchema) method with the JSON Schema. To get validation error messages, use the IsValid(JToken, JsonSchema, IList<String> ) or Validate(JToken, JsonSchema, ValidationEventHandler) overloads.

Can we validate JSON with schema?

JSON Schema is a powerful tool. It enables you to validate your JSON structure and make sure it meets the required API. You can create a schema as complex and nested as you need, all you need are the requirements. You can add it to your code as an additional test or in run-time.

What is a JSON validator?

JSON Validator verifies that your JavaScript Object Notation adheres to the JSON specification: www.json.org. JSON Validator also formats or humanizes your JSON to render it readable following common linting practices such as multi-line and indentation.


1 Answers

It seems that someone attempted to write a test suite here

It is used in another parser project to validate its implementation:

It's in java, don't know if its fit.

(someone has written some tests for python too here)

like image 116
hellvinz Avatar answered Sep 18 '22 15:09

hellvinz