Skip to content

feat(io): reject_duplicate_keys option for JSON and NDJSON reads - #428

Merged
ihb2032 merged 1 commit into
mainfrom
feat/json-reject-duplicate-keys
Sep 26, 2026
Merged

ihb2032 merged 1 commit into
mainfrom
feat/json-reject-duplicate-keys

Conversation

@ihb2032

@ihb2032 ihb2032 commented Sep 26, 2026

Copy link
Copy Markdown
Owner

The one deferred item flagged "awaiting a decision" in the v0.6 plan. Polars, serde, and pandas all keep the last value for a repeated JSON object key, so that stays the default - unchanged, and pinned by a test. The new reject_duplicate_keys option offers the strict reading: a small lexer over the raw text finds the first repeat ahead of @json.parse (only when the option is on), comparing keys decoded so "a" and "\u0061" are the same key, scanning nested objects, and leaving malformed payloads to the parser's own diagnostic. NDJSON reports the physical line; the lazy scan_ndjson source rides the same option through its driver. Purely additive (a defaulted constructor field). 1446 tests green, coverage fully covered, all guards pass.

A repeated object key folds into the parsed Map keeping only its last
value - the serde / pandas / Polars reading, and the default stays exactly
that. The new option rejects the read instead: a small lexer over the raw
text (ahead of @json.parse, only when the option is on, so the default
read pays nothing) finds the first repeat, comparing keys decoded so
"a" and "\u0061" count as the same key exactly as they do after
parsing; nested objects are scanned too, and malformed input is left to
the parser's own diagnostic. NDJSON scans per line so the error names the
physical line; the lazy scan source rides the same option through its
driver.
@ihb2032
ihb2032 merged commit 599f8dc into main Sep 26, 2026
3 checks passed
@ihb2032
ihb2032 deleted the feat/json-reject-duplicate-keys branch September 26, 2026 10:58
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.

1 participant