Merge pull request #13 from indutny/fix/handling-files-with-whitespace

Skip whitespace at the start of string/file
This commit is contained in:
Krzysztof Gabis 2014-04-03 21:18:15 +02:00
commit 19a0d79db4
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"]},
{}, {},