# dropbox/json11 architecture

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

- Interactive diagram: https://gitdiagram.com/dropbox/json11
- Repository: https://github.com/dropbox/json11

## Overview

##### Project type and purpose
- Project Type: A standalone C++11 library (not a full-stack app or service).
- Purpose: Provide a minimal, header-only (with one .cpp implementation) JSON parser/serializer for C++11, exposing a single core type `json11::Json` that can represent null, booleans, numbers, strings, arrays, and objects.

##### File structure
- Top-level build/config files:
- CMakeLists.txt, Makefile → build system integration & installation.
- json11.pc.in → pkg-config template for library discovery.
- Library implementation:
- json11.hpp → public header containing class definitions, inline and template code.
- json11.cpp → source for any non-template code.
- Examples/Tests:
- test.cpp → simple usage or self-test harness verifying parse/dump.
- Metadata:
- README.md, LICENSE.txt → documentation and license.
- .gitignore → VCS exclusions.

##### README for additional insights
- Exposes a single type `Json` with static parse and instance dump methods.
- Leverages C++11 initializer lists for ease of object/array construction.
- Supports user-defined type conversion via `to_json()` conventions.
- No external dependencies beyond the C++11 standard library.

##### Elements
- Client Code → [include] → Public API Layer
- Public API Layer → [calls] → Parser Module → [returns] → DOM Module
- DOM Module → [calls] → Serializer Module → [outputs] → JSON string
- Build System → [builds] → Implementation (.cpp) and package metadata → [links] → Client/Test
- Blue for code modules (parser, DOM, serializer)
- Green for build/integration (CMake, pkg-config)
- Yellow for usage/test (test.cpp, client)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Usage & Tests"
        Client["Client Code"]:::usage
        Test["Test Harness (test.cpp)"]:::usage
    end

    subgraph "Code Modules"
        PublicAPI["Public API Layer\n(json11.hpp)"]:::code
        Parser["Parser Module\n(json11.cpp)"]:::code
        DOM["JSON DOM Module\n(json11.hpp)"]:::code
        Serializer["Serializer Module\n(json11.hpp/.cpp)"]:::code
    end

    subgraph "Build & Integration"
        BuildSys["Build System"]:::build
        CMake["CMakeLists.txt"]:::build
        MakefileNode["Makefile"]:::build
        PkgConfig["json11.pc.in"]:::build
    end

    subgraph "Project Metadata"
        MetadataDoc["README.md"]:::metadata
        License["LICENSE.txt"]:::metadata
        Gitignore[".gitignore"]:::metadata
    end

    %% Data and control flow
    Client -->|"include"| PublicAPI
    Test -->|"includes & links"| PublicAPI
    PublicAPI -->|"calls parse()"| Parser
    Parser -->|"returns Json instance"| DOM
    DOM -->|"calls dump()"| Serializer
    Serializer -->|"returns std::string"| Client

    %% Build relationships
    BuildSys -->|"builds"| Parser
    BuildSys -->|"builds"| Serializer
    BuildSys -->|"generates pkg-config"| PkgConfig
    BuildSys -->|"provides for linking"| Client
    BuildSys -->|"provides for linking"| Test
    BuildSys -->|"reads config"| CMake
    BuildSys -->|"reads config"| MakefileNode

    %% Click Events
    click PublicAPI "https://github.com/dropbox/json11/blob/master/json11.hpp"
    click Parser "https://github.com/dropbox/json11/blob/master/json11.cpp"
    click DOM "https://github.com/dropbox/json11/blob/master/json11.hpp"
    click Serializer "https://github.com/dropbox/json11/blob/master/json11.cpp"
    click CMake "https://github.com/dropbox/json11/blob/master/CMakeLists.txt"
    click MakefileNode "https://github.com/dropbox/json11/tree/master/Makefile"
    click PkgConfig "https://github.com/dropbox/json11/blob/master/json11.pc.in"
    click Test "https://github.com/dropbox/json11/blob/master/test.cpp"
    click MetadataDoc "https://github.com/dropbox/json11/blob/master/README.md"
    click License "https://github.com/dropbox/json11/blob/master/LICENSE.txt"
    click Gitignore "https://github.com/dropbox/json11/blob/master/.gitignore"

    %% Styles
    classDef code fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef build fill:#90EE90,stroke:#000,stroke-width:1px
    classDef usage fill:#FFFFE0,stroke:#000,stroke-width:1px
    classDef metadata fill:#FFEFD5,stroke:#000,stroke-width:1px
```
