Skip whitespace at the start of string/file

This commit is contained in:
Fedor Indutny 2014-04-03 14:59:03 +04:00
parent 148e0ccbef
commit ce73431753
2 changed files with 6 additions and 2 deletions

View File

@ -619,7 +619,10 @@ JSON_Value * json_parse_file_with_comments(const char *filename) {
} }
JSON_Value * json_parse_string(const char *string) { JSON_Value * json_parse_string(const char *string) {
if (!string || (*string != '{' && *string != '[')) if (!string)
return NULL;
skip_whitespaces(&string);
if (*string != '{' && *string != '[')
return NULL; return NULL;
return parse_value((const char**)&string, 0); return parse_value((const char**)&string, 0);
} }

View File

@ -1,4 +1,5 @@
[
[
"JSON Test Pattern pass1", "JSON Test Pattern pass1",
{"object with 1 member":["array with 1 element"]}, {"object with 1 member":["array with 1 element"]},
{}, {},