nx_json_emit.nx
buildroot/runtime/nx_json_emit.nx
about
nx_json_emit.nx -- THE canonical tiny JSON emitter (eats json-emit-dup, tranche 1).
MEASURED 2026-07-21 (deduped grep): 1027 runtime files hand-roll a private xx_puts and 473
hand-roll xx_num -- the same ~30 lines re-typed a thousand times, each copy free to drift.
This is the ONE copy. Organs migrate on touch (D001); nx_dr_semcorpus is the first tranche.
⚠PLACEMENT: lives in runtime/_hdl_build/ ONLY -- the importer set starts there and a second
copy in runtime/ would itself be new cross-tree dup-source (the guarded class, seq430);
runtime/-tree organs migrate after the staged-merge or on their own touch.
je_str/je_key do NOT escape embedded quotes -- byte-identical parity with every existing
hand-rolled copy (they emit literal constants); an escaping variant is a follow-on verb.
je_num matches the hand-rolled emitters bit-for-bit (incl. their i64-min negation limit).
Emit goes to fd 1. Every func <=6 params (seq239). No hardware writes (Rule 26).
license_tier: ORIGINAL module: nishi-core.lib.json_emit depends: nx_syscalls.nx
dependencies 1 imports · 5 importers
imports: nx_syscalls.nx
imported by: nx_cms_api.nxnx_dr_semcorpus.nxnx_json_test.nxnx_jsonl_writer.nxnx_nxtask_main.nx
structs
| none |
consts
| none |
functions
| 15 | func je_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 17 | func je_q() -> i64 { let b: *u8 = sys_mmap(1); b[0] = 34 as u8; sys_write(1, b, 1); return 0 } |
| 19 | func je_key(name: *u8) -> i64 { je_q(); je_puts(name); je_q(); je_puts(":" as *u8); return 0 } |
| 21 | func je_str(v: *u8) -> i64 { je_q(); je_puts(v); je_q(); return 0 } |
| 23 | func je_num(v: i64) -> i64 |
| 36 | func je_kv_num(name: *u8, v: i64) -> i64 { je_key(name); je_num(v); return 0 } |
| 38 | func je_kv_str(name: *u8, v: *u8) -> i64 { je_key(name); je_str(v); return 0 } |