code wiki / (root) / nx_json_emit.nx

nx_json_emit.nx

buildroot/runtime/nx_json_emit.nx

2114 B38 linesdepth 2pulls 2 transitivereach 8 importersview sourcekind librarytopic json
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_json_emit.nx nx_cms_api.nx nx_dr_semcorpus.nx nx_json_test.nx nx_jsonl_writer.nx nx_nxtask_main.nx

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

15func 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 }
called by 4: sc_kv_errmainje_keyje_str calls 1: sys_write
17func je_q() -> i64 { let b: *u8 = sys_mmap(1); b[0] = 34 as u8; sys_write(1, b, 1); return 0 }
19func je_key(name: *u8) -> i64 { je_q(); je_puts(name); je_q(); je_puts(":" as *u8); return 0 }
called by 2: je_kv_numje_kv_str calls 2: je_qje_puts
21func je_str(v: *u8) -> i64 { je_q(); je_puts(v); je_q(); return 0 }
called by 1: je_kv_str calls 2: je_qje_puts
23func je_num(v: i64) -> i64
called by 2: mainje_kv_num calls 2: sys_mmapsys_write
36func je_kv_num(name: *u8, v: i64) -> i64 { je_key(name); je_num(v); return 0 }
calls 2: je_keyje_num
38func je_kv_str(name: *u8, v: *u8) -> i64 { je_key(name); je_str(v); return 0 }
calls 2: je_keyje_str