From 6fcbc470e606d77354bb6dfd7a01d5e244f17ed0 Mon Sep 17 00:00:00 2001 From: Jeff Mathews Date: Thu, 7 Jul 2022 20:45:40 -0600 Subject: [PATCH] Update tiny-json.c fix for json_getProperty not finding the object if it's the first element. --- tiny-json.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tiny-json.c b/tiny-json.c index 795715c..fb93db3 100644 --- a/tiny-json.c +++ b/tiny-json.c @@ -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 ) )