Turning on JSON5 also enables comments
Includes the simple test case.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 => [
|
||||
|
||||
Reference in New Issue
Block a user