Merge pull request #9 from namazso/array

allow arrays be root objects
pull/12/head
Rafa García 3 years ago committed by GitHub
commit 08a32cacbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      tiny-json.c

@ -69,7 +69,7 @@ static bool isEndOfPrimitive( char ch );
/* Parse a string to get a json. */
json_t const* json_createWithPool( char *str, jsonPool_t *pool ) {
char* ptr = goBlank( str );
if ( !ptr || *ptr != '{' ) return 0;
if ( !ptr || (*ptr != '{' && *ptr != '[') ) return 0;
json_t* obj = pool->init( pool );
obj->name = 0;
obj->sibling = 0;
@ -325,7 +325,7 @@ static void add( json_t* obj, json_t* property ) {
* @retval Pointer to first character after the value. If success.
* @retval Null pointer if any error occur. */
static char* objValue( char* ptr, json_t* obj, jsonPool_t* pool ) {
obj->type = JSON_OBJ;
obj->type = *ptr == '{' ? JSON_OBJ : JSON_ARRAY;
obj->u.c.child = 0;
obj->sibling = 0;
ptr++;

Loading…
Cancel
Save