JSONValidator is a JavaScript tool to validate JSON syntax, supporting objects, arrays, strings, numbers, booleans, and null values. It parses JSON text using lexical and syntactic analysis, outputting "Valid JSON" (exit code 0) or "Invalid JSON" with an error message (exit code 1). Built for beginners, it’s ideal for learning parsing techniques and handles ASCII-based JSON with robust error checking. Perfect for validating JSON against the JSON_checker test suite.
- Validates JSON objects and arrays
- Supports strings, numbers, booleans, and null
- Provides clear error messages for invalid JSON
- Beginner-friendly command-line interface
- Node.js
- Clone the repository:
git clone https://github.com/AsifMinar/JSONValidator.git
- Ensure
json_parser.jsis in the project directory.
Run the program with Node.js:
node json_parser.jsEdit json_parser.js to test different JSON inputs:
checkJSON('{"key": "value"}'); // Valid JSON
checkJSON('{"key": 123, "array": [true, null]}'); // Valid JSON
checkJSON('{"key": bad}'); // Invalid JSON- Modify test cases in
json_parser.jswith your JSON strings. - Run
node json_parser.jsto see results. - Use the JSON_checker suite for advanced testing.
- Supports ASCII JSON only (no escaped characters like
\"). - Focused on validation, not data extraction.