Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ext/json/ext/parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2496,6 +2496,9 @@ static VALUE cResumableParser_partial_value(VALUE self)
JSON_ResumableParser *original_parser = ResumableParser_acquire(self, false);
JSON_ResumableParser parser = *original_parser;

parser.state.frames = &parser.frames;
parser.state.value_stack = &parser.value_stack;

if (parser.value_stack.head == 0) {
return Qnil;
}
Expand Down
14 changes: 14 additions & 0 deletions test/json/resumable_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@ def test_partial_value
assert_partial_value([1, { "a" => 1, "b" => { "c" => nil } }], '[1, { "a": 1, "b": { "c"')
end

def test_partial_value_issue_1005
data = <<~JSON
[
[]
]
JSON
data.each_line do |line|
@parser << line
@parser.parse
@parser.partial_value # This unexpected parse error doesn't happen if we comment this out
end
assert_equal [[]], @parser.value
end

def test_partial_value_missing
assert_nil @parser.partial_value
end
Expand Down
Loading