diff --git a/tests.c b/tests.c index 830fdb3..51ecb9e 100644 --- a/tests.c +++ b/tests.c @@ -134,19 +134,37 @@ static int primitive( void ) { } static int text( void ) { - json_t pool[2]; - unsigned const qty = sizeof pool / sizeof *pool; + + { + json_t pool[2]; + unsigned const qty = sizeof pool / sizeof *pool; - char str[] = "{\"a\":\"\\tThis text: \\\"Hello\\\".\\n\"}"; + char str[] = "{\"a\":\"\\tThis text: \\\"Hello\\\".\\n\"}"; - json_t const* json = json_create( str, pool, qty ); - check( json ); + json_t const* json = json_create( str, pool, qty ); + check( json ); - json_t const* a = json_getProperty( json, "a" ); - check( a ); - check( JSON_TEXT == json_getType( a ) ); - check( !strcmp( "\tThis text: \"Hello\".\n", json_getValue( a ) ) ); + json_t const* a = json_getProperty( json, "a" ); + check( a ); + check( JSON_TEXT == json_getType( a ) ); + check( !strcmp( "\tThis text: \"Hello\".\n", json_getValue( a ) ) ); + } + + { + json_t pool[2]; + unsigned const qty = sizeof pool / sizeof *pool; + + char str[] = "{\"name\":\"Christiane Eluère\"}"; + + json_t const* json = json_create( str, pool, qty ); + check( json ); + json_t const* name = json_getProperty( json, "name" ); + check( name ); + check( JSON_TEXT == json_getType( name ) ); + check( !strcmp( "Christiane Eluère", json_getValue( name ) ) ); + + } done(); } diff --git a/tiny-json.c b/tiny-json.c index 03d5acc..4f28f13 100644 --- a/tiny-json.c +++ b/tiny-json.c @@ -116,8 +116,8 @@ static char getCharFromUnicode( char const* str ) { * @retval Pointer to first non white space after the string. If success. * @retval Null pointer if any error occur. */ static char* parseString( char* str ) { - char* head = str; - char* tail = str; + unsigned char* head = (unsigned char*)str; + unsigned char* tail = (unsigned char*)str; for( ; *head >= ' '; ++head, ++tail ) { if ( *head == '\"' ) { *tail = '\0';