From 702720c2cc1a11314a4046819ab763f759c37a6b Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Sat, 22 Nov 2014 14:34:12 -0800 Subject: fix bare object parsing closes #2 and #16 --- ext/ffi_yajl/ext/parser/parser.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'ext/ffi_yajl/ext') diff --git a/ext/ffi_yajl/ext/parser/parser.c b/ext/ffi_yajl/ext/parser/parser.c index e2481cd..a2813af 100644 --- a/ext/ffi_yajl/ext/parser/parser.c +++ b/ext/ffi_yajl/ext/parser/parser.c @@ -26,6 +26,7 @@ void set_value(CTX *ctx, VALUE val) { rb_hash_aset(last, key, val); break; default: + rb_ary_push(stack, val); break; } } @@ -49,8 +50,6 @@ void end_object(CTX *ctx) { rb_ivar_set(ctx->self, rb_intern("key"), rb_ary_pop(key_stack)); if ( RARRAY_LEN(stack) > 1 ) { set_value(ctx, rb_ary_pop(stack)); - } else { - rb_ivar_set(ctx->self, rb_intern("finished"), rb_ary_pop(stack)); } } @@ -211,7 +210,7 @@ static VALUE mParser_do_yajl_parse(VALUE self, VALUE str, VALUE yajl_opts) { goto raise; } yajl_free(hand); - return rb_ivar_get(self, rb_intern("finished")); + return rb_ary_pop(rb_ivar_get(self, rb_intern("stack"))); raise: if (hand) { @@ -230,4 +229,3 @@ void Init_parser() { utf8Encoding = rb_utf8_encoding(); #endif } - -- cgit v1.2.1