From 8f640b6d665926c6687d6138c8f6485b43c3a857 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Sat, 14 Jun 2014 16:50:46 -0700 Subject: support yajl parser options --- ext/ffi_yajl/ext/parser/parser.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (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 5100e2d..e2481cd 100644 --- a/ext/ffi_yajl/ext/parser/parser.c +++ b/ext/ffi_yajl/ext/parser/parser.c @@ -186,9 +186,21 @@ static VALUE mParser_do_yajl_parse(VALUE self, VALUE str, VALUE yajl_opts) { hand = yajl_alloc(&callbacks, NULL, (void *)&ctx); - if (rb_hash_aref(yajl_opts, ID2SYM(rb_intern("yajl_allow_comments")))) { + if (rb_hash_aref(yajl_opts, ID2SYM(rb_intern("yajl_allow_comments"))) == Qtrue) { yajl_config(hand, yajl_allow_comments, 1); } + if (rb_hash_aref(yajl_opts, ID2SYM(rb_intern("yajl_dont_validate_strings"))) == Qtrue) { + yajl_config(hand, yajl_dont_validate_strings, 1); + } + if (rb_hash_aref(yajl_opts, ID2SYM(rb_intern("yajl_allow_trailing_garbage"))) == Qtrue) { + yajl_config(hand, yajl_allow_trailing_garbage, 1); + } + if (rb_hash_aref(yajl_opts, ID2SYM(rb_intern("yajl_allow_multiple_values"))) == Qtrue) { + yajl_config(hand, yajl_allow_multiple_values, 1); + } + if (rb_hash_aref(yajl_opts, ID2SYM(rb_intern("yajl_allow_partial_values"))) == Qtrue) { + yajl_config(hand, yajl_allow_partial_values, 1); + } if ((stat = yajl_parse(hand, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str))) != yajl_status_ok) { err = yajl_get_error(hand, 1, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str)); -- cgit v1.2.1