# zserge/jsmn architecture

> Architecture diagram of the GitHub repository zserge/jsmn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zserge/jsmn
- Repository: https://github.com/zserge/jsmn

## Overview

JSMN is a minimal, header-only C JSON tokenizer. A caller initializes parser state, passes a JSON buffer and caller-owned token array to the parse API, and receives token counts or errors; tokens reference positions in the original input rather than copying values. The header documents incremental parsing and count-only sizing with a NULL token array. The source excerpt is partial, so internal parsing detail is limited to the visible string, primitive, and container routines.

Main entry points: [`jsmn.h`](https://github.com/zserge/jsmn/blob/master/jsmn.h) (Parser API)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_caller(("C caller"))
node_api["Parser API<br/>[jsmn.h]"]
node_state["Parser state<br/>[jsmn.h]"]
node_scan["Token scanning<br/>[jsmn.h]"]
node_input["JSON buffer"]
node_tokens["Token array"]
node_result["Count or error"]

node_caller -->|"calls init"| node_api
node_api -->|"initializes"| node_state
node_caller -->|"calls parse"| node_api
node_caller -->|"supplies JSON"| node_input
node_caller -->|"supplies capacity"| node_tokens
node_api -->|"uses state"| node_state
node_api -->|"scans input"| node_scan
node_scan -->|"reads buffer"| node_input
node_scan -->|"writes tokens"| node_tokens
node_api -->|"returns count or error"| node_result

click node_api "https://github.com/zserge/jsmn/blob/master/jsmn.h"
click node_state "https://github.com/zserge/jsmn/blob/master/jsmn.h"
click node_scan "https://github.com/zserge/jsmn/blob/master/jsmn.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_caller,node_input,node_tokens,node_result toneIndigo
class node_api toneMint
class node_state,node_scan toneTeal
```

## Components

### Other components

- **C caller**
- [Parser API](https://github.com/zserge/jsmn/blob/master/jsmn.h): `jsmn.h`
- [Parser state](https://github.com/zserge/jsmn/blob/master/jsmn.h): `jsmn.h`
- [Token scanning](https://github.com/zserge/jsmn/blob/master/jsmn.h): `jsmn.h`
- **JSON buffer**
- **Token array**
- **Count or error**

## Connections

- C caller → Parser API: calls init
- Parser API → Parser state: initializes
- C caller → Parser API: calls parse
- C caller → JSON buffer: supplies JSON
- C caller → Token array: supplies capacity
- Parser API → Parser state: uses state
- Parser API → Token scanning: scans input
- Token scanning → JSON buffer: reads buffer
- Token scanning → Token array: writes tokens
- Parser API → Count or error: returns count or error
