JW_ARR

Table of Contents

JW_ARR

Description

Write a JSON array from a vector. Each item is rendered using the provided writer. Handles inserting commas between elements.

Parameters

NameDirectionDescription
jin,outThe target string to append to.
arrinA vector to iterate over.
itemoutIterator variable for the current item.
writerinCode block that appends JSON for each item.

Usage example (from documentation)

  JW_ARR(json, some_vec, s, {
      JW_STR(json, s);
  });

Success

Appends a JSON array to json

Failure

Does not return on failure

Usage example (Cross-references)

    }                                                                                                              \
    StrAppendf(&(j), "\"%s\":", k);                                                                                \
    JW_ARR(j, arr, item, writer);                                                                                  \
    } while (0)

Share :

Related Posts

JR_OBJ

JR_OBJ Description Read a JSON object using a custom field reader expression. The macro parses the object and invokes the provided code block for each key-value pair. If the key is not recognized or parsing fails, the value is skipped.

Read More

JR_ARR_KV

JR_ARR_KV Description Conditionally parse a JSON array if key matches expected name.

Read More

JW_OBJ

JW_OBJ Description Begin a JSON object and write key-value entries using JW_*_KV macros. This macro must be used as a wrapper for other JW_*_KV macros to generate a JSON object. Tracks whether commas are needed between entries using an internal flag.

Read More