# boostorg/json architecture

> Architecture diagram of the GitHub repository boostorg/json, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/boostorg/json
- Repository: https://github.com/boostorg/json

## Overview

##### Main Components

a. Core Components:
- Value Container System
- JSON value types (object, array, string, number, boolean, null)
- Storage management
- Parser System
- Streaming parser
- Basic parser
- Parse options handling
- Serializer System
- Serialization engine
- Format options handling
- Memory Management System
- Allocator support
- Storage pointer management

b. Support Systems:
- Error Handling System
- UTF-8 Processing
- Platform Abstraction Layer

##### Component Relationships

**[Input JSON Text] → [Parser System] → [Value Container] → [Serializer System] → [Output JSON Text]**
- ↕
- [Memory Management]

##### Detailed Component Breakdown

Value Container System:
**[Value Container]**
- Object Container
- Array Container
- String Container
- Number Handler
- Storage Management

Parser System:
**[Parser System]**
- Stream Parser
- Basic Parser
- Parse Options
- Error Handler

##### Key Architectural Points to Highlight

a. Header-only capability:
**[Application] ←→ [Header-only Interface]**
- ↓
- [Implementation]

b. Memory management:
**[Allocator System] → [Storage Ptr] → [Components]**

##### Performance Features

Highlight:
- Constant-time object key lookup
- Streaming capabilities
- Stack buffer optimizations
- Memory allocation strategies

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Core Component]:::core
        L2[Support System]:::support
        L3[Input/Output]:::io
        L4["Data Flow"]
        L5-.-L6["Optional Path"]
        L7["Error Path"]:::error
    end

    classDef core fill:#a8d1f0
    classDef support fill:#ffd700
    classDef io fill:#90EE90
    classDef error stroke:#ff0000,stroke-width:2px

    Input["Input JSON Text"]:::io
    Output["Output JSON Text"]:::io

    subgraph ValueSystem["Value Container System"]
        Value["Value Container"]:::core
        Object["Object Container"]:::core
        Array["Array Container"]:::core
        String["String Container"]:::core
        Number["Number Handler"]:::core
        Storage["Storage Management"]:::core
    end

    subgraph ParserSystem["Parser System"]
        StreamParser["Stream Parser"]:::core
        BasicParser["Basic Parser"]:::core
        ParseOpt["Parse Options"]:::core
        ParserErr["Error Handler"]:::core
    end

    subgraph SerializerSystem["Serializer System"]
        Serializer["Serialization Engine"]:::core
        SerializeOpt["Format Options"]:::core
    end

    subgraph SupportSystems["Support Systems"]
        ErrorHandling["Error Handling"]:::support
        UTF8["UTF-8 Processing"]:::support
        Platform["Platform Abstraction"]:::support
    end

    subgraph MemorySystem["Memory Management System"]
        Allocator["Allocator Support"]:::support
        StoragePtr["Storage Pointer"]:::support
    end

    Input --> StreamParser
    Input --> BasicParser
    StreamParser --> Value
    BasicParser --> Value
    Value --> Serializer
    Serializer --> Output

    Value --> Object
    Value --> Array
    Value --> String
    Value --> Number
    Value --> Storage

    StoragePtr --> Value
    StoragePtr --> Object
    StoragePtr --> Array
    StoragePtr --> String

    ErrorHandling -.-> ParserSystem
    ErrorHandling -.-> SerializerSystem
    UTF8 -.-> ParserSystem
    UTF8 -.-> SerializerSystem
    Platform -.-> ValueSystem

    click Value "https://github.com/boostorg/json/blob/develop/include/boost/json/value.hpp"
    click Object "https://github.com/boostorg/json/blob/develop/include/boost/json/object.hpp"
    click Array "https://github.com/boostorg/json/blob/develop/include/boost/json/array.hpp"
    click String "https://github.com/boostorg/json/blob/develop/include/boost/json/string.hpp"
    click StreamParser "https://github.com/boostorg/json/blob/develop/include/boost/json/stream_parser.hpp"
    click BasicParser "https://github.com/boostorg/json/blob/develop/include/boost/json/basic_parser.hpp"
    click ParseOpt "https://github.com/boostorg/json/blob/develop/include/boost/json/parse_options.hpp"
    click Serializer "https://github.com/boostorg/json/blob/develop/include/boost/json/serializer.hpp"
    click SerializeOpt "https://github.com/boostorg/json/blob/develop/include/boost/json/serialize_options.hpp"
    click StoragePtr "https://github.com/boostorg/json/blob/develop/include/boost/json/storage_ptr.hpp"
    click ErrorHandling "https://github.com/boostorg/json/blob/develop/include/boost/json/error.hpp"
    click UTF8 "https://github.com/boostorg/json/blob/develop/include/boost/json/detail/utf8.hpp"
    click Platform "https://github.com/boostorg/json/blob/develop/include/boost/json/detail/config.hpp"
```
