From 6331cb1753e454ece6345a43ae242d4eea0eccec Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 13 Jul 2016 16:42:03 -0400 Subject: [PATCH] cmJson.h/c : Added cmJsonMemberAtIndex(). --- cmJson.c | 8 ++++++++ cmJson.h | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmJson.c b/cmJson.c index 3dce4c1..58c210b 100644 --- a/cmJson.c +++ b/cmJson.c @@ -1456,6 +1456,14 @@ cmJsRC_t cmJsonMemberType( const cmJsonNode_t* np, const char* label, unsig return rc; } +cmJsonNode_t* cmJsonMemberAtIndex( cmJsonNode_t* objNodePtr, unsigned idx ) +{ + cmJsonNode_t* cnp = cmJsonArrayElement( objNodePtr, idx ); + assert( cmJsonIsPair(cnp) ); + return cnp; +} + + cmJsRC_t cmJsonUIntMember( const cmJsonNode_t* np, const char* label, unsigned* retPtr ) { cmJsonNode_t* vp; diff --git a/cmJson.h b/cmJson.h index 7d5c939..2ddc033 100644 --- a/cmJson.h +++ b/cmJson.h @@ -197,7 +197,10 @@ extern "C" { // Return the type of a member value. cmJsRC_t cmJsonMemberType( const cmJsonNode_t* objectNodePtr, const char* label, unsigned* typeIdRef ); - + + // Return the pair at the specified index. Use cmJsonChildCount() to get the count of pairs in the object. + cmJsonNode_t* cmJsonMemberAtIndex( cmJsonNode_t* objNodePtr, unsigned idx ); + // Return values associated with the member values in the object // pointed to by object objectNodePtr. cmJsRC_t cmJsonUIntMember( const cmJsonNode_t* objectNodePtr, const char* label, unsigned* retPtr );