Can `ResumableParser` return whether the last `partial_value` container is completed or not?
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Start by reproducing the two JSON::ResumableParser chunk examples in the issue and inspect how partial_value is populated after parse. Trace the parser state for a completed versus incomplete last record; done means callers can reliably distinguish those cases, including the workaround scenarios described.
Written by the indexing model from the issue text.
Description
This is not a critical feature request.
I'm trying to migrate to json gem from json-stream gem in https://github.com/groonga/groonga-command-parser/ by JSON::ResumableParser.
It parses records to be loaded to Groonga (a full text search engine with column store). The records use the following format:
[
{"column_name1": "record1's column_value1", "column_name2": 2, ...},
{"column_name1": "record2's column_value1", "column_name2": 2, ...},
...
]
groonga-command-parser wants to process a record as soon as it's completed. For example, it wants to process the first record when the following chunk is processed:
[
{"column_name1": "record1's column_value1", "column_name2": 2, ...},
We can do it by the following script:
require "json"
parser = JSON::ResumableParser.new
parser << <<-CHUNK
[
{"column1": "value1"},
CHUNK
parser.parse
p parser.partial_value[0] # => {"column1" => "value1"}
But it doesn't work with the following chunk:
[
{"column_name1": "record1's column_value1",
We can't know whether the record is completed or not:
require "json"
parser = JSON::ResumableParser.new
parser << <<-CHUNK
[
{"column1": "value1",
CHUNK
parser.parse
p parser.partial_value[0] # => {"column1" => "value1"} # This is not completed yet
groonga-command-parser has a workaround for it. It ignores the last record:
require "json"
parser = JSON::ResumableParser.new
parser << <<-CHUNK
[
{"column1": "value1"},
CHUNK
parser.parse
p parser.partial_value[0..-2] # => []
parser << <<-CHUNK
{"column1": "value2"},
CHUNK
parser.parse
p parser.partial_value[0..-2] # => [{"column1" => "value1"}] # 1st record
If we can detect whether a record in this example is completed or not, it's useful. But this is not a critical feature request because there is a workaround for this case.
- Dominant language
- Ruby
- Stars
- 785
- Forks
- 390
- Avg merge
- 7h 14m
- Merged PRs (30d)
- 15
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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 ruby/json
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
Output formatting differences between jRuby 10.0.0.1 and Ruby 3.4 when converting Float to JSON.Possibly taken @headius claimed this 450 days ago. Openjruby
ruby/json#817 · 3 comments · 1 reaction · 1 assignee ·
Maintainers usually reply within 1 day
-
Don't cache JRuby runtime in static fieldsMay be free again @headius claimed this 727 days ago, and no pull request is open. Openjruby
ruby/json#707 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
new feature
Difficulty 5/5 Over a week Newbie friendliness 25/100
Maintainers usually reply within 1 day
-
bug jruby
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
Similar issues
-
🐛 bug 👩💻 équipe CE 🧑🏭 entreprises
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
betagouv/conseillers-entreprises#4808 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
yosiat/panko_serializer#250 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
cline/mcp-marketplace#3886 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100