Skip to content

fix: allow_missing_commas: false was ignored for array elements - #87

Merged
dsherret merged 2 commits into
mainfrom
fix_missing_commas_in_arrays
Jul 26, 2026
Merged

fix: allow_missing_commas: false was ignored for array elements#87
dsherret merged 2 commits into
mainfrom
fix_missing_commas_in_arrays

Conversation

@dsherret

Copy link
Copy Markdown
Member

Array parsing never consulted allow_missing_commas, so strict parsing accepted invalid JSON like [1 2] and [01] (the latter scans as two numbers). Object properties already handled this—now array elements do too, erroring with ExpectedComma at the position right after the previous element.

The fix is in both parser implementations, which covers all four entry points:

  • parse_to_ast::parse_array — also covers cst::CstRootNode::parse
  • JsoncParser::scan_array_comma — the shared path for parse_to_value and parse_to_serde_value

A word in an array ([1 a ]) still reports Unexpected word rather than a missing comma, since a word is never a valid array element regardless of the option.

Closes #84

dsherret added 2 commits July 26, 2026 09:52
Array parsing never consulted `allow_missing_commas`, so strict parsing
accepted invalid JSON like `[1 2]` and `[01]`. Now array elements error
with `ExpectedComma` the same way object properties do.

Closes #84
- keep reporting `Unexpected word` for words in arrays, which are never
  valid elements regardless of `allow_missing_commas`
- debug assert the previous value was consumed in `scan_array_comma`
- more tests: cst, unterminated arrays, comments on the serde path and
  arrays that are still valid when missing commas are not allowed
@dsherret
dsherret merged commit da39681 into main Jul 26, 2026
3 checks passed
@dsherret
dsherret deleted the fix_missing_commas_in_arrays branch July 26, 2026 14:07
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.

allow_missing_commas: false is ignored for array elements

1 participant