Update tiny-json.c

fix for json_getProperty not finding the object if it's the first element.
This commit is contained in:
Jeff Mathews 2022-07-07 20:45:40 -06:00 committed by GitHub
parent 025cdde5f2
commit 6fcbc470e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,6 +41,9 @@ typedef struct jsonStaticPool_s {
/* Search a property by its name in a JSON object. */
json_t const* json_getProperty( json_t const* obj, char const* property ) {
if ( obj->name && !strcmp( obj->name, property ) ) {
return obj;
}
json_t const* sibling;
for( sibling = obj->u.c.child; sibling; sibling = sibling->sibling )
if ( sibling->name && !strcmp( sibling->name, property ) )