mirror of
https://github.com/rafagafe/tiny-json.git
synced 2025-03-12 19:25:30 +00:00
allow arrays be root objects
This commit is contained in:
parent
1c62646c71
commit
46e9fb710e
@ -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;
|
||||
@ -324,7 +324,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…
Reference in New Issue
Block a user