summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-08-07 12:12:41 -0400
committerLamont Granquist <lamont@scriptkiddie.org>2014-08-07 12:12:41 -0400
commit24922dbf881adf72ad828b24eb616c92ce96fb17 (patch)
treeba2daaf200b7e40845764976c01d5f2545aa847c
parent3d63d763184980f2423f11070c8b1b4001c2a495 (diff)
downloadffi-yajl-24922dbf881adf72ad828b24eb616c92ce96fb17.tar.gz
change allow_comment default to true
this matches yajl-ruby's default and fixes a regression in Chef where we stopped accepting comments.
-rw-r--r--lib/ffi_yajl/parser.rb7
-rw-r--r--spec/ffi_yajl/parser_spec.rb8
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/ffi_yajl/parser.rb b/lib/ffi_yajl/parser.rb
index d095011..b6c8ce2 100644
--- a/lib/ffi_yajl/parser.rb
+++ b/lib/ffi_yajl/parser.rb
@@ -41,7 +41,12 @@ module FFI_Yajl
raise ArgumentError, "options check_utf8 and dont_validate_strings are both true which conflict"
end
- yajl_opts[:yajl_allow_comments] = @opts[:allow_comments]
+ yajl_opts[:yajl_allow_comments] = true
+
+ if @opts.key?(:allow_comments)
+ yajl_opts[:yajl_allow_comments] = @opts[:allow_comments]
+ end
+
yajl_opts[:yajl_dont_validate_strings] = (@opts[:check_utf8] == false || @opts[:dont_validate_strings])
yajl_opts[:yajl_allow_trailing_garbage] = @opts[:allow_trailing_garbage]
yajl_opts[:yajl_allow_multiple_values] = @opts[:allow_multiple_values]
diff --git a/spec/ffi_yajl/parser_spec.rb b/spec/ffi_yajl/parser_spec.rb
index f896bf7..c6ca3e4 100644
--- a/spec/ffi_yajl/parser_spec.rb
+++ b/spec/ffi_yajl/parser_spec.rb
@@ -32,6 +32,14 @@ describe "FFI_Yajl::Parser" do
expect(parser).to eq({"key"=>"value"})
end
end
+
+ context "by default" do
+ let(:options) { }
+
+ it "should parse" do
+ expect(parser).to eq({"key"=>"value"})
+ end
+ end
end
context "when json has multiline comments" do