Document how to deserialize from a prefix of an io::Read without blocking until EOF
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 48/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- documentation
Research direction
Start with the documentation for serde_json::from_reader and the Deserializer::from_reader example shown in the issue. Explain that from_reader waits for EOF and rejects trailing data, then document deserializing a prefix from a persistent stream with T::deserialize. Done means the documented behavior and example clearly distinguish both use cases.
Written by the indexing model from the issue text.
Description
The behavior of serde_json::from_reader is that it expects the input stream to end after the deserialized object. If the stream contains trailing data, that is considered an error. If the stream does not end, such as in the case of a persistent socket connection, then from_reader would not return. This is the correct behavior for from_reader for example when deserializing from a File, in which we don't want to silently allow trailing garbage. It is possible instead to deserialize from a prefix of an input stream without looking for EOF by managing your own Deserializer:
let mut de = serde_json::Deserializer::from_reader(stream);
let t = T::deserialize(&mut de)?;
- Dominant language
- Rust
- Stars
- 5.6k
- Forks
- 670
- PR merge metrics
- No merged PRs in 30d
Contributor 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 serde-rs/json
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100