You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A top-level number at the end of the input is never emitted (no way to signal end of input) #50
When the input ends right after a top-level number, onValue is never called for it. The tokenizer only knows a number is complete when it sees a byte that cannot continue it, and the parser has no end() (or similar) method to say that no more bytes will come. Strings, literals, arrays and objects at the top level are emitted as soon as their last byte is written. So a stream or file whose whole content is a number (a valid JSON text) gives no value, and the caller cannot tell it apart from empty input.
Environment: jsonparse 1.3.1 (npm) and master at b2d8bc6, Node 26.10.0, macOS 27.0.1.
The five inputs are the JSON texts 1 (1 byte), 1 followed by a newline, "a", true and [1]. The script prints each one before the values it got. Paste into an empty folder:
Expected: [1] for number.json once the end of input is signalled. RFC 8259, section 2: "A JSON text is a serialized value", and a number is a value.
Cause: the NUMBER1/NUMBER3 branch of write (jsonparse.js L240-L281 in 1.3.1, L244-L277 on master) appends digits and emits the token only from its default: case, when a non-number byte arrives; nothing else flushes this.string.
Activity