# codixor/rs-json architecture

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

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

## Overview

rs-json is a Rust JSON parsing and data-conversion library. Its principal workflow accepts text or UTF-8 bytes, tokenizes and validates JSON under shared limits, then exposes a borrowed flat-tape document for access to values. Alternative branches provide bounded pull events for streams, typed Serde conversion, newline-delimited processing, JSON Pointer selection, file snapshots, legacy compatibility, and JSON-LD builders. The relationships below rely on the README and the supplied source excerpts/index; unsampled implementation details are not inferred.

Main entry points: [`src/lib.rs`](https://github.com/codixor/rs-json/blob/main/src/lib.rs) (Parse API), [`src/lex/slice.rs`](https://github.com/codixor/rs-json/blob/main/src/lex/slice.rs) (Slice lexer), [`src/stream/mod.rs`](https://github.com/codixor/rs-json/blob/main/src/stream/mod.rs) (Event grammar), [`src/dom/mod.rs`](https://github.com/codixor/rs-json/blob/main/src/dom/mod.rs) (Tape document)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_parse["Parsing Core"]
  node_api["Parse API<br/>[lib.rs]"]
  node_limits["Limits config<br/>[config.rs]"]
  node_slice_lexer["Slice lexer<br/>[slice.rs]"]
  node_scan["Byte scanning<br/>[mod.rs]"]
  node_escape["Escape decoding<br/>[unescape.rs]"]
  node_tape["Tape document<br/>[mod.rs]"]
  node_small_tape["Inline tape<br/>[small.rs]"]
  node_value["Value access<br/>[value.rs]"]
  node_numbers["Number conversion<br/>[num.rs]"]
end

subgraph group_streaming["Streaming Inputs"]
  node_read_lexer["Reader lexer<br/>[read.rs]"]
  node_grammar["Event grammar<br/>[mod.rs]"]
  node_input["File snapshots<br/>[input.rs]"]
  node_ndjson["NDJSON records<br/>[ndjson.rs]"]
  node_pointer["Pointer selection<br/>[pointer.rs]"]
end

subgraph group_convert["Values and Conversion"]
  node_serde["Serde codec<br/>[serde_codec.rs]"]
  node_errors["Diagnostics<br/>[error.rs]"]
end

subgraph group_extensions["Optional APIs"]
  node_ld_core["JSON-LD builders<br/>[builder.rs]"]
  node_ld_document["JSON-LD document<br/>[document.rs]"]
  node_google_profiles["Google profiles"]
  node_legacy["Legacy API<br/>[legacy.rs]"]
end

node_caller(("Library caller"))

node_caller -->|"calls"| node_api
node_api -->|"uses defaults"| node_limits
node_api -->|"tokenizes input"| node_slice_lexer
node_slice_lexer -->|"scans bytes"| node_scan
node_slice_lexer -->|"validates escapes"| node_escape
node_api -->|"builds document"| node_tape
node_tape -->|"tries inline storage"| node_small_tape
node_caller -->|"requests events"| node_grammar
node_grammar -->|"reads tokens"| node_read_lexer
node_grammar -->|"enforces bounds"| node_limits
node_caller -->|"loads file"| node_input
node_caller -->|"processes records"| node_ndjson
node_caller -->|"selects paths"| node_pointer
node_caller -->|"encodes or decodes"| node_serde
node_serde -->|"converts values"| node_tape
node_value -->|"converts numbers"| node_numbers
node_caller -->|"builds JSON-LD"| node_ld_core
node_ld_core -.->|"forms document"| node_ld_document
node_caller -->|"uses profiles"| node_google_profiles
node_caller -->|"uses compatibility API"| node_legacy
node_api -->|"returns diagnostics"| node_errors

click node_api "https://github.com/codixor/rs-json/blob/main/src/lib.rs"
click node_limits "https://github.com/codixor/rs-json/blob/main/src/config.rs"
click node_slice_lexer "https://github.com/codixor/rs-json/blob/main/src/lex/slice.rs"
click node_read_lexer "https://github.com/codixor/rs-json/blob/main/src/lex/read.rs"
click node_scan "https://github.com/codixor/rs-json/blob/main/src/scan/mod.rs"
click node_escape "https://github.com/codixor/rs-json/blob/main/src/unescape.rs"
click node_grammar "https://github.com/codixor/rs-json/blob/main/src/stream/mod.rs"
click node_tape "https://github.com/codixor/rs-json/blob/main/src/dom/mod.rs"
click node_small_tape "https://github.com/codixor/rs-json/blob/main/src/dom/small.rs"
click node_value "https://github.com/codixor/rs-json/blob/main/src/dom/value.rs"
click node_numbers "https://github.com/codixor/rs-json/blob/main/src/num.rs"
click node_input "https://github.com/codixor/rs-json/blob/main/src/input.rs"
click node_ndjson "https://github.com/codixor/rs-json/blob/main/src/ndjson.rs"
click node_pointer "https://github.com/codixor/rs-json/blob/main/src/stream/pointer.rs"
click node_serde "https://github.com/codixor/rs-json/blob/main/src/serde_codec.rs"
click node_errors "https://github.com/codixor/rs-json/blob/main/src/error.rs"
click node_ld_core "https://github.com/codixor/rs-json/blob/main/src/ld/builder.rs"
click node_ld_document "https://github.com/codixor/rs-json/blob/main/src/ld/document.rs"
click node_google_profiles "https://github.com/codixor/rs-json/tree/main/src/ld/google"
click node_legacy "https://github.com/codixor/rs-json/blob/main/src/legacy.rs"

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_api,node_limits,node_slice_lexer,node_scan,node_escape,node_tape,node_small_tape,node_value,node_numbers toneBlue
class node_read_lexer,node_grammar,node_input,node_ndjson,node_pointer toneAmber
class node_serde,node_errors toneMint
class node_ld_core,node_ld_document,node_google_profiles,node_legacy toneRose
class node_caller toneIndigo
```

## Components

### Parsing Core

- [Parse API](https://github.com/codixor/rs-json/blob/main/src/lib.rs): `src/lib.rs`
- [Limits config](https://github.com/codixor/rs-json/blob/main/src/config.rs): `src/config.rs`
- [Slice lexer](https://github.com/codixor/rs-json/blob/main/src/lex/slice.rs): `src/lex/slice.rs`
- [Byte scanning](https://github.com/codixor/rs-json/blob/main/src/scan/mod.rs): `src/scan/mod.rs`
- [Escape decoding](https://github.com/codixor/rs-json/blob/main/src/unescape.rs): `src/unescape.rs`
- [Tape document](https://github.com/codixor/rs-json/blob/main/src/dom/mod.rs): `src/dom/mod.rs`
- [Inline tape](https://github.com/codixor/rs-json/blob/main/src/dom/small.rs): `src/dom/small.rs`
- [Value access](https://github.com/codixor/rs-json/blob/main/src/dom/value.rs): `src/dom/value.rs`
- [Number conversion](https://github.com/codixor/rs-json/blob/main/src/num.rs): `src/num.rs`

### Streaming Inputs

- [Reader lexer](https://github.com/codixor/rs-json/blob/main/src/lex/read.rs): `src/lex/read.rs`
- [Event grammar](https://github.com/codixor/rs-json/blob/main/src/stream/mod.rs): `src/stream/mod.rs`
- [File snapshots](https://github.com/codixor/rs-json/blob/main/src/input.rs): `src/input.rs`
- [NDJSON records](https://github.com/codixor/rs-json/blob/main/src/ndjson.rs): `src/ndjson.rs`
- [Pointer selection](https://github.com/codixor/rs-json/blob/main/src/stream/pointer.rs): `src/stream/pointer.rs`

### Values and Conversion

- [Serde codec](https://github.com/codixor/rs-json/blob/main/src/serde_codec.rs): `src/serde_codec.rs`
- [Diagnostics](https://github.com/codixor/rs-json/blob/main/src/error.rs): `src/error.rs`

### Optional APIs

- [JSON-LD builders](https://github.com/codixor/rs-json/blob/main/src/ld/builder.rs): `src/ld/builder.rs`
- [JSON-LD document](https://github.com/codixor/rs-json/blob/main/src/ld/document.rs): `src/ld/document.rs`
- [Google profiles](https://github.com/codixor/rs-json/tree/main/src/ld/google): `src/ld/google`
- [Legacy API](https://github.com/codixor/rs-json/blob/main/src/legacy.rs): `src/legacy.rs`

### Other components

- **Library caller**

## Connections

- Library caller → Parse API: calls
- Parse API → Limits config: uses defaults (evidence: `src/lib.rs`)
- Parse API → Slice lexer: tokenizes input
- Slice lexer → Byte scanning: scans bytes (evidence: `src/lex/slice.rs`)
- Slice lexer → Escape decoding: validates escapes (evidence: `src/lex/slice.rs`)
- Parse API → Tape document: builds document (evidence: `src/lib.rs`)
- Tape document → Inline tape: tries inline storage (evidence: `src/dom/mod.rs`)
- Library caller → Event grammar: requests events
- Event grammar → Reader lexer: reads tokens (evidence: `src/stream/mod.rs`)
- Event grammar → Limits config: enforces bounds (evidence: `src/stream/mod.rs`)
- Library caller → File snapshots: loads file
- Library caller → NDJSON records: processes records
- Library caller → Pointer selection: selects paths
- Library caller → Serde codec: encodes or decodes
- Serde codec → Tape document: converts values
- Value access → Number conversion: converts numbers (evidence: `src/dom/value.rs`)
- Library caller → JSON-LD builders: builds JSON-LD
- JSON-LD builders → JSON-LD document: forms document
- Library caller → Google profiles: uses profiles
- Library caller → Legacy API: uses compatibility API
- Parse API → Diagnostics: returns diagnostics (evidence: `src/lib.rs`)
