code wiki / (root) / nx_json_v1.nx

nx_json_v1.nx

buildroot/runtime/nx_json_v1.nx

7313 B233 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind orphan librarytopic json
docsdependenciesstructsconstsfunctions

about

json.nx -- pull-style JSON parser (Phase G12, RFC 8259). Research / reference: RFC 8259 — The JavaScript Object Notation (JSON) Data Interchange Format Crockford 2002 — json.org, the original spec Design: pull-style / event-driven parser. The caller invokes json_next(p) in a loop; each call emits one event: JSON_NULL / JSON_BOOL / JSON_INT / JSON_STRING JSON_ARRAY_BEGIN / JSON_ARRAY_END JSON_OBJECT_BEGIN / JSON_OBJECT_END JSON_KEY (for object member names) JSON_END (end of input) JSON_ERROR (malformed input) Zero heap allocation per event. String values are returned as (start, len) slices into the original input buffer; the caller copies if they need persistence. Scope: RFC 8259 compliant for well-formed input. Skips whitespace per spec, supports \" \\ \/ \b \f \n \r \t escape sequences in strings. Number parsing handles integers; \uXXXX unicode escapes and fractional numbers deferred to a follow-up.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_json_v1.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

structs

46struct JsonParser

consts

34const JSON_END: i64 = 0
35const JSON_NULL: i64 = 1
36const JSON_BOOL: i64 = 2
37const JSON_INT: i64 = 3
38const JSON_STRING: i64 = 4
39const JSON_ARRAY_BEGIN: i64 = 5
40const JSON_ARRAY_END: i64 = 6
41const JSON_OBJECT_BEGIN: i64 = 7
42const JSON_OBJECT_END: i64 = 8
43const JSON_KEY: i64 = 9
44const JSON_ERROR: i64 = 10

functions

59func json_new(src: *u8, len: i64) -> *JsonParser
calls 1: sys_mmap
70func json_skip_ws(p: *JsonParser) -> i64
called by 1: json_next
89func json_peek(p: *JsonParser) -> i64
called by 1: json_next
97func json_read_string(p: *JsonParser) -> i64
called by 1: json_next
123func json_read_int(p: *JsonParser) -> i64
called by 1: json_next
152func json_match(p: *JsonParser, word: *u8, len: i64) -> i64
called by 1: json_next
165func json_next(p: *JsonParser) -> i64