Project Overview

Project Purpose and Objectives

This project implements a robust C-language JSON processing library that provides parsing, manipulation, comparison, serialization, and printing of JSON data. The core objective is to offer a lightweight, efficient, and standards-compliant JSON parser and utility that can be embedded in C applications. The system focuses on:

The major functionalities are implemented primarily in src/json.c and declared in src/json.h. The entry point in src/main.c initializes and runs JSON parsing tests defined in the test directory, ensuring correctness and stability.

Example Workflows and Use Cases

JSON Parsing and Querying

  1. Parsing JSON Text
    Developers can use json_parse() to convert a JSON string into an in-memory json_value tree. This function handles all JSON types and nested structures.

  2. Accessing JSON Data
    For objects, json_object_get() retrieves values by key. For arrays, direct indexing on the json_value array field can be performed.

  3. Manipulating JSON Values
    Use functions like json_array_push() to append elements to arrays or json_object_set_take_key() to set key-value pairs in objects.

  4. Comparing JSON Structures
    json_equal() performs a deep comparison of two JSON value trees, useful for test assertions or synchronization checks.

  5. Serializing JSON
    json_stringify() converts a json_value tree back into a pretty-printed JSON string for storage or transmission.

  6. Memory Management
    After usage, json_free() releases all allocated memory related to the JSON value tree.

Test Execution Workflow

flowchart TD
A[JSON Text Input] --> B["json_parse()"]
B --> C[json_value Tree]
C --> D{Operation}
D -->|Access/Modify| E["json_object_get(), json_array_push()"]
D -->|Compare| F["json_equal()"]
D -->|Serialize| G["json_stringify()"]
G --> H[JSON Text Output]
C --> I["json_free()"]

Stack and Technologies

These technologies were chosen to ensure cross-platform build and development workflows, maximize performance, and maintain minimal external dependencies.

High-Level Architecture

The architecture is modular and layered around core JSON processing logic, build automation, and testing framework:

Interactions:

graph TB
TestRunner["Test Runner (src/main.c)"] --> JSONLib["JSON Library (src/json.c/h)"]
JSONLib --> TestSuite["Tests (test/test.c, test.json)"]
BuildSystem["Build System (Ninja)"] --> Executable["Executable (main)"]
Executable --> TestRunner
InstallScripts["Install Scripts (bin/install)"] -.-> BuildSystem
InstallScripts -.-> Toolchain["Toolchain (LLVM, Ninja)"]

Developer Navigation

Frontend Developers Start Here

Backend Developers Focus On

Build and Toolchain Maintenance

Testing and Validation


flowchart LR
Start["Start Test Suite"] --> ParseInput["Parse JSON Input"]
ParseInput --> Validate["Validate Structure"]
Validate -->|Equal| Pass["Test Passed"]
Validate -->|Not Equal| Fail["Test Failed"]
Fail --> Report["Print Mismatch Details"]
Pass --> End["End Test Suite"]
Report --> End