Browse Source

cmJson.h/c : Added cmJsonMemberAtIndex().

master
kevin 8 years ago
parent
commit
6331cb1753
2 changed files with 12 additions and 1 deletions
  1. 8
    0
      cmJson.c
  2. 4
    1
      cmJson.h

+ 8
- 0
cmJson.c View File

@@ -1456,6 +1456,14 @@ cmJsRC_t      cmJsonMemberType( const cmJsonNode_t* np, const char* label, unsig
1456 1456
   return rc;
1457 1457
 }
1458 1458
 
1459
+cmJsonNode_t* cmJsonMemberAtIndex( cmJsonNode_t* objNodePtr, unsigned idx )
1460
+{
1461
+  cmJsonNode_t* cnp = cmJsonArrayElement( objNodePtr, idx );
1462
+  assert( cmJsonIsPair(cnp) );
1463
+  return cnp;
1464
+}  
1465
+
1466
+
1459 1467
 cmJsRC_t      cmJsonUIntMember(    const cmJsonNode_t* np, const char* label, unsigned* retPtr )
1460 1468
 { 
1461 1469
   cmJsonNode_t* vp;

+ 4
- 1
cmJson.h View File

@@ -197,7 +197,10 @@ extern "C" {
197 197
   
198 198
   // Return the type of a member value.
199 199
   cmJsRC_t     cmJsonMemberType( const cmJsonNode_t* objectNodePtr, const char* label, unsigned* typeIdRef );
200
-  
200
+
201
+  // Return the pair at the specified index.  Use cmJsonChildCount() to get the count of pairs in the object.
202
+  cmJsonNode_t* cmJsonMemberAtIndex( cmJsonNode_t* objNodePtr, unsigned idx );
203
+
201 204
   // Return values associated with the member values in the object
202 205
   // pointed to by object objectNodePtr.
203 206
   cmJsRC_t      cmJsonUIntMember(   const cmJsonNode_t* objectNodePtr, const char* label, unsigned* retPtr );

Loading…
Cancel
Save