JR_ARR

Table of Contents

JR_ARR

Description

Read a JSON array using a custom value reader expression. The macro parses a JSON array and calls the user-provided code block for each element. If the value can’t be parsed or reader fails to advance the iterator, the value is skipped.

Parameters

NameDirectionDescription
siin,outStream iterator to read from.

Usage example (from documentation)

  JR_ARR(si, {
      MyStruct tmp = {0};
      JR_OBJ(si, {
          JR_INT_KV(si, "x", tmp.x);
          JR_FLT_KV(si, "y", tmp.y);
      });
      VecPush(&data.items, tmp);
  });

Success

All values processed or skipped gracefully

Failure

Logs error and restores si on structural or read failure

Usage example (Cross-references)

    do {                                                                                                               \
    if (!StrCmpZstr(&key, (k))) {                                                                                  \
    JR_ARR(si, reader);                                                                                        \
    }                                                                                                              \
    } while (0)

Share :

Related Posts

JR_BOOL

JR_BOOL Description Read a JSON boolean value from stream and assign to target.

Read More

JR_BOOL_KV

JR_BOOL_KV Description Read a boolean key-value pair if key matches.

Read More

JR_INT_KV

JR_INT_KV Description Read an integer key-value pair if key matches.

Read More