A robust JSON Validator written in Go.
This project is a solution to the "Build Your Own JSON Parser" coding challenge. It validates whether a given input is a valid JSON object according to standard syntax rules.
- Syntax Validation: Checks for correctly paired braces, brackets, and quotes.
- Type Support: Validates standard JSON types (strings, numbers, booleans, null, arrays, and objects).
- Error Handling: Returns appropriate exit codes (0 for valid, 1 for invalid) suitable for CI/CD pipelines or scripting.
- End-to-End Testing: Includes a comprehensive suite of integration tests.
To build and run this project, you need:
- Go (version 1.18 or higher recommended)
-
Clone the repository
git clone [https://github.com/ahmedsameha1/ccjsonvalidator.git](https://github.com/ahmedsameha1/ccjsonvalidator.git) cd ccjsonvalidator -
Download dependencies
go mod download
-
Build the project
go build -o ccjsonvalidator ./cmd/cli/ccjsonparser.go
You can run the validator directly using the built binary or via go run. The tool accepts a file path as an argument.
go run cmd/cli/ccjsonparser.go path/to/file.json./ccjsonvalidator path/to/file.json| Exit Code | Status | Description |
|---|---|---|
| 0 | Valid |
The file contains valid JSON. |
| 1 | Invalid |
The file contains invalid JSON or syntax errors. |
The project is structured with both unit tests and end-to-end integration tests.
go test ./...go test ./endtoendtestsccjsonvalidator/
├── cmd/ # Application entry point
├── internal/
│ └── app/ # Core validation logic and parser implementation
├── endtoendtests/ # Integration tests with sample JSON files
├── tests/ # JSON file for end-to-end tests
├── functions.go # Helper utility functions
├── go.mod # Go module definition
└── README.md # Project documentation