From ce734317536ef2cfb2aedad87a3d3b4c33167423 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 3 Apr 2014 14:59:03 +0400 Subject: [PATCH] Skip whitespace at the start of string/file --- parson.c | 5 ++++- tests/test_1_1.txt | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/parson.c b/parson.c index ecf733f..b7fb251 100644 --- a/parson.c +++ b/parson.c @@ -619,7 +619,10 @@ JSON_Value * json_parse_file_with_comments(const char *filename) { } 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 parse_value((const char**)&string, 0); } diff --git a/tests/test_1_1.txt b/tests/test_1_1.txt index 70e2685..da78ef4 100644 --- a/tests/test_1_1.txt +++ b/tests/test_1_1.txt @@ -1,4 +1,5 @@ -[ + + [ "JSON Test Pattern pass1", {"object with 1 member":["array with 1 element"]}, {},