in source/core_json.c [1762:1813]
JSONStatus_t JSON_Iterate( const char * buf,
size_t max,
size_t * start,
size_t * next,
JSONPair_t * outPair )
{
JSONStatus_t ret;
size_t key, keyLength, value, valueLength;
if( ( buf == NULL ) || ( start == NULL ) || ( next == NULL ) ||
( outPair == NULL ) )
{
ret = JSONNullParameter;
}
else if( ( max == 0U ) || ( *start >= max ) || ( *next > max ) )
{
ret = JSONBadParameter;
}
else
{
skipSpace( buf, start, max );
if( *next <= *start )
{
*next = *start + 1U;
skipSpace( buf, next, max );
}
ret = iterate( buf, max, start, next, &key, &keyLength,
&value, &valueLength );
}
if( ret == JSONSuccess )
{
JSONTypes_t t = getType( buf[ value ] );
if( t == JSONString )
{
/* strip the surrounding quotes */
value++;
valueLength -= 2U;
}
outPair->key = ( key == 0U ) ? NULL : &buf[ key ];
outPair->keyLength = keyLength;
outPair->value = &buf[ value ];
outPair->valueLength = valueLength;
outPair->jsonType = t;
}
return ret;
}