[API Proposal]: Save comma flag in `JsonReaderState`.
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by reading the JsonReaderState and Utf8JsonReader code that tracks commas, including the existing _trailingCommaBeforeComment flag. The issue proposes preserving comma state so streamed reads can advance to the next token; check the reader’s state and streaming tests to understand current behavior. Done means partial-token reads can resume at the token start after consuming the comma, with existing reader behavior covered.
Written by the indexing model from the issue text.
Description
Background and motivation
When large json is iterated in streamed way and doesn't fit the buffer, it is preferred to leave the buffer at the start of the next token since token is what we are gonna read. Commas are for syntax only, they are not meant to be consumed, reader doesn't even return them.
However, at the moment reader stops consuming right before the comma when next token is partial.
Assume that we are reading [ "token 1" , "token 2" ]. Minimum reading steps are: [, , "token 1", , , "token 2", , ].
First two whitespaces are independent since they are handled by SkipWhiteSpace(). However, since encountered comma is not saved in a JsonReaderState, reader can't advance past comma between two tokens, thus both comma and all whitespaces after it have to be present along with token 2, otherwise token 2 will throw as unexpected(because reader expects a comma).
API Proposal
Add a flag to JsonReaderState to note that comma is encountered. Thus reader will be able to consume past comma and stop right at the beginning of the token.
The flag probably can replace previous _trailingCommaBeforeComment as well.
API Usage
Alternative Designs
No response
Risks
No response
- Dominant language
- C#
- Stars
- 18.5k
- Forks
- 5.8k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 588
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/runtime
-
area-CodeGen-coreclr untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
dotnet/runtime#138181 · 1 comment ·
Maintainers usually reply within 1 day
-
area-System.Collections untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
dotnet/runtime#138090 · 1 comment ·
Maintainers usually reply within 1 day
-
area-System.Text.Json untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dotnet/runtime#138089 · 1 comment ·
Maintainers usually reply within 1 day
-
area-Setup untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
dotnet/runtime#137376 · 1 comment ·
Maintainers usually reply within 1 day
-
area-System.Memory untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
dotnet/runtime#137334 · 4 comments ·
Maintainers usually reply within 1 day
Similar issues
-
Add `net10.0`Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
dotnet-outdated/dotnet-outdated#871 ·
Maintainers usually reply within 1 day
-
triage/untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
unoplatform/uno#26676 ·
Maintainers usually reply within 1 day
-
.NET bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
jhaizhou-ops/S2Arm#2177 · 3 comments ·
Maintainers usually reply within 1 day