Turning on JSON5 also enables comments

Includes the simple test case.
This commit is contained in:
Andrew Johnson
2020-07-07 00:36:11 -05:00
parent 456e774d85
commit 00ac15cec5
2 changed files with 33 additions and 1 deletions

View File

@@ -90,12 +90,13 @@ yajl_config(yajl_handle h, int option, ...)
va_start(ap, option);
switch(opt) {
case yajl_allow_json5:
opt |= yajl_allow_comments; /* JSON5 allows comments */
case yajl_allow_comments:
case yajl_dont_validate_strings:
case yajl_allow_trailing_garbage:
case yajl_allow_multiple_values:
case yajl_allow_partial_values:
case yajl_allow_json5:
if (va_arg(ap, int)) h->flags |= opt;
else h->flags &= ~opt;
break;

View File

@@ -54,6 +54,37 @@ sub cases {
"memory leaks:\t0"
]
},
{
name => "simple_with_comments",
opts => [
-5
],
input => [
"{",
" \"this\": \"is\", // ignore this",
" \"really\": \"simple\",",
" /* ignore",
"this",
"too * / ",
"** //",
"(/",
"******/",
" \"json\": \"right?\"",
"}",
""
],
gives => [
"map open '{'",
"key: 'this'",
"string: 'is'",
"key: 'really'",
"string: 'simple'",
"key: 'json'",
"string: 'right?'",
"map close '}'",
"memory leaks:\t0"
]
},
{
name => "trailing_commas",
opts => [