Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ohler55 committed Aug 1, 2024
1 parent 97e57af commit 559433b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ext/oj/usual.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ static void close_object(ojParser p) {
}
rb_hash_bulk_insert(d->vtail - head, head, obj);
d->ktail = d->khead + c->ki;
if (0 == head - d->vhead && rb_block_given_p()) {

// printf("*** close %ld - %d\n", head - d->vhead, rb_block_given_p());
if (1 == head - d->vhead && rb_block_given_p()) {
rb_yield(obj);
// TBD decrement vtail?
d->vtail--;
Expand Down
12 changes: 10 additions & 2 deletions test/test_parser_usual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,17 @@ def test_decimal

def test_multi
p = Oj::Parser.new(:usual)
puts p.just_one
#puts p.parse('{"b":{"x":2}}')
puts p.parse('{"a":1}{"b":{"x":2}} {"c":3}') { |j| puts j }
#puts p.parse('{"a":1}{"b":{"x":2}} {"c":3}') { |j| puts j }

reader, writer = IO.pipe
writer.write('{"a":1}')
writer.write('{"b":{"x":2}}')
writer.write('{"c":3}')
writer.close

p.load(reader) { |data| puts data }
reader.close
end

def test_omit_null
Expand Down

0 comments on commit 559433b

Please sign in to comment.