Skip to content

A robust JSON lexer and parser implemented in C#. This project tokenizes JSON strings and validates them according to the JSON specification (RFC 8259). Includes custom error handling for invalid JSON formats, making it an essential tool for developers working within the .NET ecosystem.

Notifications You must be signed in to change notification settings

Shaieb524/json-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Custom JSON Lexer and Parser

This project provides a **custom implementation** of a **JSON lexer** and **JSON parser** written in **C#**. The lexer tokenizes JSON strings, and the parser validates and interprets the tokenized input according to the **JSON specification (RFC 8259)**.

## Features

- **Custom Lexer**: Tokenizes JSON strings into meaningful tokens such as objects, arrays, strings, numbers, booleans, and null values.
- **Custom Parser**: Validates the sequence of tokens to ensure they conform to the JSON specification and interprets the JSON structure.
- **Error Handling**: Detects and reports errors such as invalid numbers, control characters in strings, and improperly formatted JSON.
- **C# Implementation**: The entire project is implemented in C#, making it suitable for developers working within the .NET ecosystem.

## Project Structure

- **JsonLexer.cs**: Contains the `JsonLexer` class responsible for tokenizing the JSON input string.
- **JsonParser.cs**: Contains the `JsonParser` class responsible for parsing the list of tokens generated by the lexer.
- **JsonToken.cs**: Contains the `JsonToken` class and the `JsonTokenType` enumeration, which define the structure of a token and the types of tokens that the lexer can generate.
- **Program.cs**: The entry point of the application. It demonstrates how to use the lexer and parser to validate and parse a JSON string.


## Getting Started

### Prerequisites

- **.NET Core SDK**: Make sure you have .NET Core SDK installed on your machine. You can download it from the official [.NET website](https://dotnet.microsoft.com/download).

### Running the Project

1. **Clone the Repository**: Clone this repository to your local machine.

   ```bash
   git clone https://github.com/your-username/json-lexer-parser.git

2. **Navigate to the Project Directory**:
    ```bash
    cd json-parser

3. **Run the project**:
    ```bash
    dotnet run
 

About

A robust JSON lexer and parser implemented in C#. This project tokenizes JSON strings and validates them according to the JSON specification (RFC 8259). Includes custom error handling for invalid JSON formats, making it an essential tool for developers working within the .NET ecosystem.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages