Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofmodule highlight.module·originates fromworld 07158574-5…

json

JSON syntax highlighter. Pure `(text) -> { Segment }`. Mirrors the algorithm of the deleted Rust `highlight_json` (renderer.rs): emits object keys via lookahead-for-`:`, handles `\` escapes inside strings, recognises numbers with scientific notation, and colors structural punctua…

byzero-proxy @ DESKTOP-DB3UJOJ·posted 2mo ago
What it does

json

JSON syntax highlighter. Pure (text) -> { Segment }. Mirrors the algorithm of the deleted Rust highlight_json (renderer.rs): emits object keys via lookahead-for-:, handles \ escapes inside strings, recognises numbers with scientific notation, and colors structural punctuation ({ } [ ] , :). Colors flow from ui.getToken("code.<role>") via the active theme; hardcoded fallbacks match the deleted Rust values when no theme is registered.

Exports

  • highlight(text: string) -> { Segment } — tokenize a JSON string into colored segments for the zui code renderer. The module returns this function directly.

Types:

  • Segment = { text: string, color: string, monospace: boolean }

Usage

local highlight = require("@builtin::modules.zui.highlight.json")
local segments  = highlight('{"a": 1, "b": "two"}')

Notes

  • Pure function — no side effects, no state. Safe to call any time.
  • The ui.getToken lookup runs once per highlighter call (5 FFI calls) rather than per byte, so the inner tokenize loop is allocation-light.
  • Keys are disambiguated from string values by a lookahead past whitespace for : — matches the deleted Rust algorithm exactly.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

ZuiHighlightJson Module JSON syntax highlighter. Pure `(text) -> { Segment }`. Mirrors the algorithm of the deleted Rust `highlight_json` (renderer.rs): values via lookahead-for-`:`, handles `\` escapes inside strings, recognises numbers with scientific notation, and colors structural punctuation (`{ } [ ] , :`). Colors flow from `ui.getToken("code.<role>")` via the active theme. Hardcoded fallbacks below match the deleted Rust values for use when no theme is registered. The module returns the highlighter function directly: local highlight = require("modules.highlight.json") local segments = highlight('{"key": "value"}')

token(role: string, fallback: string) → string

Internal: resolve `code.<role>` from the active theme, falling back to the deleted Rust constant when no `ui` global or no theme is registered.

argtypedescription
rolestring
fallbackstring

isDigit(b: number) → boolean

argtypedescription
bnumber

isAlpha(b: number) → boolean

argtypedescription
bnumber

isWhitespace(b: number) → boolean

argtypedescription
bnumber

push(segments: ?, text: ?, color: ?) → void

argtypedescription
segments?
text?
color?

highlightJson(text: string) →

Tokenize a JSON string into colored text segments for the zui code renderer. Distinguishes object keys (via lookahead for `:`) from string values, colors numbers (including scientific notation), bool/null literals, and structural punctuation. defaults to `""` when nil. for the zui code renderer.

argtypedescription
textstringThe JSON source to highlight. Coerced via `tostring` and

examples

local segments = highlight('{"a": 1, "b": "two"}')
⌬ Types
Segment = { text: string, color: string, monospace: boolean }

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

3items
·
other · born here
▤file
▲ 0↑ born
backing path · modules/highlight.module/json.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.