6 static bool visit_element(
const char * name,
unsigned index,
const JST_Element * element,
JST_Visitor visitor,
void * user_context );
9 for(
unsigned i = 0; i <
object->count; ++i ) {
10 if( ! visit_element( object->
items[i]->
name, -1U, &(object->
items[i]->
element), visitor, user_context )) {
18 for(
unsigned i = 0; i < array->
count; ++i ) {
19 if( ! visit_element( NULL, i, &(array->
items[i]->
element), visitor, user_context )) {
26 static bool visit_element(
const char * name,
unsigned index,
const JST_Element * element,
JST_Visitor visitor,
void * context ) {
27 (*visitor)( name, index,
true, element, context );
28 switch( element->type ) {
30 if( ! visit_object( &(element->value.object), visitor, context )) {
35 if( ! visit_array( &(element->value.array), visitor, context )) {
41 (*visitor)( name, index,
false, element, context );
46 if(( root == NULL )||( visitor == NULL )) {
struct JST_Pair_ ** items
Array of JST_Pair, ordered by JST_Pair.name to ease search with bsearch()
char * name
This property's name.
A JSON object, a sorted set of named-value pairs.
JST_Error JST_walk(const JST_Element *root, JST_Visitor visitor, void *context)
An element is a typed value.
struct JST_ArrayItem_ ** items
Array of JST_ArrayItem.
unsigned count
Cardinality of the previous array.
JST_Element element
The value associated with the name.