Skip to content

ebrahim-s-ebrahim/myJsonParser

Repository files navigation

myJsonParser

Simple.Json.Parser is a simple JSON parser library for .NET.

Features

  • Parse JSON into dictionaries and lists

  • Handles nested objects and arrays

  • Validates JSON syntax

  • Lightweight and easy to use

Getting Started

Install the latest version of the JsonParser package from NuGet:


dotnet add package Simple.Json.Parser

Parse a JSON string:

var json = @"{"name": "John", "age": 30}";

var parser = new JsonParser();

var data = parser.ParseJson(json);

Console.WriteLine(data["name"]); // prints "John"

Usage

The main entry point is the JsonParser class.

  • To parse JSON, call ParseJson() with the JSON string.

  • This returns a Dictionary<string, object> for parsed JSON objects, and List for JSON arrays.

  • Primitive values like strings, numbers, and booleans are represented as usual .NET types.

  • The parser will throw exceptions for invalid JSON syntax. Use a try/catch block to handle errors gracefully:

    try {
    
    var data = parser.ParseJson(json);
    
    } catch (JsonParseException ex) {
    
    // invalid JSON
    
    }

About

Simple.Json.Parser is a simple JSON parser library for .NET.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages