# vba-tools/vba-json architecture

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

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

## Overview

##### Main Components
- JsonConverter Module: Represent the core conversion functions (e.g., ParseJson and ConvertToJson); this is the heart of the library.
- Options/Configuration: Show that the converter supports various options (like UseDoubleForLargeNumbers, AllowUnquotedKeys, EscapeSolidus) that affect JSON parsing and generation behavior.
- Test/Specs Component: Include the specs folder (with Specs.bas and the Excel test workbook) to indicate how the project is validated independently.
- External Dependencies: Identify the dependencies as noted in the README:
- Microsoft Scripting Runtime (Windows-only)
- VBA-Dictionary (for cross-platform compatibility)
- Supporting Files and Metadata: Include configuration and metadata files (.editorconfig, .gitattributes, .gitignore, vba-block.toml, LICENSE) as ancillary elements that relate to code formatting, version control, project configuration, and distribution.

##### Relationships and Data Flow
- Data flow from an input JSON string into the ParseJson function, which converts it into a VBA Dictionary or Collection.
- How the processed data may be manipulated by user code and then passed back into the ConvertToJson function to produce a JSON string.
- Test path: how test files under specs interact with the JsonConverter module, acting as a client that sends/receives JSON data.

##### Architectural Patterns and Design Principles
- Modularity: the conversion logic is separated into its own module for easy integration into any VBA project.
- Mention extensibility: through configurable options that allow the user to customize parsing behavior.
- That while the project is not structured as a multi-tier application, it clearly delineates between core functionality (JSON parsing/conversion) and testing/validation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Library Subgraph
    subgraph "Core Library"
        Parse["ParseJson()"]:::core
        Data["Data Structure (Dictionary/Collection)"]:::data
        Convert["ConvertToJson()"]:::core
        Parse -->|"outputs"| Data
        Data -->|"provides input"| Convert
    end

    %% External Input/Output and Configuration
    JSONIn["JSON Input"]:::input
    JSONOut["JSON Output"]:::output
    Config["Configuration Options"]:::config

    JSONIn -->|"calls"| Parse
    Convert -->|"returns"| JSONOut
    Config -->|"customizes"| Parse
    Config -->|"customizes"| Convert

    %% External Dependencies
    ExternalSRT["Microsoft Scripting Runtime"]:::external
    ExternalDict["VBA-Dictionary"]:::external

    ExternalSRT ---|"dependency"| Parse
    ExternalSRT ---|"dependency"| Convert
    ExternalDict ---|"dependency"| Parse
    ExternalDict ---|"dependency"| Convert

    %% Test/Specs Subgraph
    subgraph "Test/Specs"
        SpecsBas["Specs.bas"]:::test
        SpecsWb["VBA-JSON - Specs.xlsm"]:::test
    end

    SpecsBas ---|"validates"| Parse
    SpecsBas ---|"validates"| Convert
    SpecsWb ---|"validates"| Parse
    SpecsWb ---|"validates"| Convert

    %% Supporting Files & Metadata Subgraph
    subgraph "Supporting Files & Metadata"
        Editor[".editorconfig"]:::support
        Gitat[".gitattributes"]:::support
        Git[".gitignore"]:::support
        VBATom["vba-block.toml"]:::support
        License["LICENSE"]:::support
    end

    %% Click Events (do not display file paths in node labels)
    click Parse "https://github.com/vba-tools/vba-json/blob/master/JsonConverter.bas"
    click SpecsBas "https://github.com/vba-tools/vba-json/blob/master/specs/Specs.bas"
    click SpecsWb "https://github.com/vba-tools/vba-json/blob/master/specs/VBA-JSON - Specs.xlsm"
    click Editor "https://github.com/vba-tools/vba-json/blob/master/.editorconfig"
    click Gitat "https://github.com/vba-tools/vba-json/blob/master/.gitattributes"
    click Git "https://github.com/vba-tools/vba-json/blob/master/.gitignore"
    click VBATom "https://github.com/vba-tools/vba-json/blob/master/vba-block.toml"
    click License "https://github.com/vba-tools/vba-json/tree/master/LICENSE"

    %% Styles
    classDef core fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef input fill:#ADFF2F,stroke:#000,stroke-width:2px;
    classDef output fill:#ADFF2F,stroke:#000,stroke-width:2px;
    classDef config fill:#87CEEB,stroke:#000,stroke-width:2px;
    classDef external fill:#FF6347,stroke:#000,stroke-width:2px;
    classDef test fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef support fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef data fill:#FFA07A,stroke:#000,stroke-width:2px;
```
