Skip to content

feat: Add Reader.RawValue and Reader.Offset for raw value capture - #50

Merged
keelerm84 merged 1 commit into
v4from
mk/SDK-2760/jreader-raw-value-v4
Jul 29, 2026
Merged

feat: Add Reader.RawValue and Reader.Offset for raw value capture#50
keelerm84 merged 1 commit into
v4from
mk/SDK-2760/jreader-raw-value-v4

Conversation

@keelerm84

@keelerm84 keelerm84 commented Jul 29, 2026

Copy link
Copy Markdown
Member

Port of the v3 RawValue/Offset work (#45) to the v4 module line.

RawValue returns the next JSON value's raw bytes as a zero-copy slice of the
input (cap == len), fully validated: scalars via the tokenizer, containers via a
string-aware boundary scan plus encoding/json validation of the captured span.
Offset returns the current byte position for capturing a value parsed in place.

v4 has no easyjson backend, so the port drops the build tags and the
easyjson-specific comments/placeholder that the v3 change carried; the logic is
otherwise identical.


Note

Medium Risk
New parsing surface on the core tokenizer with container boundary scanning; behavior is heavily tested and additive, but mistakes could affect JSON acceptance or slice aliasing guarantees.

Overview
Adds Reader.RawValue() and Reader.Offset() so callers can capture the next JSON value as a zero-copy slice of the input (cap == len), or slice the buffer around an in-place parse without RawValue’s extra container scan.

RawValue validates scalars via the existing RFC 8259 tokenizer; for arrays/objects it uses a string-aware delimiter scan and then encoding/json.Valid on the captured span. Unread-token paths (e.g. after Null() probes) are handled explicitly. A new errMsgInvalidValue backs invalid container content.

Offset reports the next consume position (or the start of a pushed-back token), documented for start/end span capture with JSON whitespace trimming.

Coverage includes unit tests, encoding/json differential/oracle tests, generative runs, and scalar grammar fuzzing.

Reviewed by Cursor Bugbot for commit c72dc8d. Bugbot is set up for automated code reviews on this repo. Configure here.

Port of the v3 RawValue/Offset work (#45) to the v4 module line.

RawValue returns the next JSON value's raw bytes as a zero-copy slice of the
input (cap == len), fully validated: scalars via the tokenizer, containers via a
string-aware boundary scan plus encoding/json validation of the captured span.
Offset returns the current byte position for capturing a value parsed in place.

v4 has no easyjson backend, so the port drops the build tags and the
easyjson-specific comments/placeholder that the v3 change carried; the logic is
otherwise identical.
@keelerm84
keelerm84 marked this pull request as ready for review July 29, 2026 18:26
@keelerm84
keelerm84 requested a review from a team as a code owner July 29, 2026 18:26
@keelerm84
keelerm84 merged commit 8eb580f into v4 Jul 29, 2026
14 checks passed
@keelerm84
keelerm84 deleted the mk/SDK-2760/jreader-raw-value-v4 branch July 29, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants