A lightweight C# project for basic JSON parsing, providing functionality to lex JSON files, parse them into C# objects, and stringify C# objects.
-
Lexer:
- Lex JSON files to tokenize them for parsing.
-
Parser:
- Parse JSON files into C# objects.
- Support for basic data types such as numbers, bools, strings, arrays, and objects.
-
Stringify:
- Convert C# objects back to JSON strings.
-
Lexer:
var lexer = new Lexer(@" {"id": 4} "); // init lexer with source Console.WriteLine(lexer.GetTokens()); // get tokens
-
Parser:
var parser = new Parser(lexer.GetTokens()); // init parser with tokens JSON json = parser.Parse();
-
Stringify:
var printer = new PrettyPrinter(); Console.WriteLine(printer.Stringifiy(json));
-
Nested Access:
Console.WriteLine(json["properties:age:title"]); Console.WriteLine(json["required:1"]);
- .NET SDK Link
- Clone the repository:
> git clone https://github.com/masaftic/JSONSharp
- Run the project:
> cd JSONSharp/
> dotnet run <File>