Skip to content

Commit 474ee12

Browse files
committed
Fix the apps/json_parse "-s" (strict) option so it actually does something, and default to non-strict.
1 parent 07148f3 commit 474ee12

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

apps/json_parse.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,14 @@ static int parseit(int fd, int (*callback)(struct json_object *))
7474
fprintf(stderr, "unable to allocate json_tokener: %s\n", strerror(errno));
7575
return 1;
7676
}
77-
json_tokener_set_flags(tok, JSON_TOKENER_STRICT
78-
#ifdef JSON_TOKENER_ALLOW_TRAILING_CHARS
79-
| JSON_TOKENER_ALLOW_TRAILING_CHARS
80-
#endif
81-
);
77+
if (strict_mode)
78+
{
79+
json_tokener_set_flags(tok, JSON_TOKENER_STRICT
80+
#ifdef JSON_TOKENER_ALLOW_TRAILING_CHARS
81+
| JSON_TOKENER_ALLOW_TRAILING_CHARS
82+
#endif
83+
);
84+
}
8285

8386
// XXX push this into some kind of json_tokener_parse_fd API?
8487
// json_object_from_fd isn't flexible enough, and mirroring

0 commit comments

Comments
 (0)