Trailing commas now require a json5 parser
Modifies the yajl test case to add the -5 option
This commit is contained in:
@@ -332,7 +332,8 @@ yajl_do_parse(yajl_handle hand, const unsigned char * jsonText,
|
||||
case yajl_tok_right_bracket: {
|
||||
yajl_state s = yajl_bs_current(hand->stateStack);
|
||||
if (s == yajl_state_array_start ||
|
||||
s == yajl_state_array_need_val)
|
||||
((hand->flags & yajl_allow_json5) &&
|
||||
(s == yajl_state_array_need_val)))
|
||||
{
|
||||
if (hand->callbacks &&
|
||||
hand->callbacks->yajl_end_array)
|
||||
@@ -404,7 +405,8 @@ yajl_do_parse(yajl_handle hand, const unsigned char * jsonText,
|
||||
case yajl_tok_right_brace: {
|
||||
yajl_state s = yajl_bs_current(hand->stateStack);
|
||||
if (s == yajl_state_map_start ||
|
||||
s == yajl_state_map_need_key) {
|
||||
((hand->flags & yajl_allow_json5) &&
|
||||
(s == yajl_state_map_need_key))) {
|
||||
if (hand->callbacks && hand->callbacks->yajl_end_map) {
|
||||
_CC_CHK(hand->callbacks->yajl_end_map(hand->ctx));
|
||||
}
|
||||
|
||||
@@ -7,6 +7,31 @@
|
||||
|
||||
sub cases {
|
||||
my $VAR1 = [
|
||||
{
|
||||
name => "trailing_commas",
|
||||
opts => [
|
||||
-5
|
||||
],
|
||||
input => [
|
||||
"{\"array\":[1,2,],\"map\":{\"a\":1,},}",
|
||||
""
|
||||
],
|
||||
gives => [
|
||||
"map open '{'",
|
||||
"key: 'array'",
|
||||
"array open '['",
|
||||
"integer: 1",
|
||||
"integer: 2",
|
||||
"array close ']'",
|
||||
"key: 'map'",
|
||||
"map open '{'",
|
||||
"key: 'a'",
|
||||
"integer: 1",
|
||||
"map close '}'",
|
||||
"map close '}'",
|
||||
"memory leaks:\t0"
|
||||
]
|
||||
},
|
||||
{
|
||||
name => "difficult_json_c_test_case_with_comments",
|
||||
opts => [
|
||||
@@ -3000,29 +3025,6 @@ sub cases {
|
||||
"memory leaks:\t0"
|
||||
]
|
||||
},
|
||||
{
|
||||
name => "trailing_commas",
|
||||
opts => [],
|
||||
input => [
|
||||
"{\"array\":[1,2,],\"map\":{\"a\":1,},}",
|
||||
""
|
||||
],
|
||||
gives => [
|
||||
"map open '{'",
|
||||
"key: 'array'",
|
||||
"array open '['",
|
||||
"integer: 1",
|
||||
"integer: 2",
|
||||
"array close ']'",
|
||||
"key: 'map'",
|
||||
"map open '{'",
|
||||
"key: 'a'",
|
||||
"integer: 1",
|
||||
"map close '}'",
|
||||
"map close '}'",
|
||||
"memory leaks:\t0"
|
||||
]
|
||||
},
|
||||
{
|
||||
name => "true",
|
||||
opts => [],
|
||||
|
||||
Reference in New Issue
Block a user