JW_INT

Table of Contents

JW_INT

Description

Append an integer value to a JSON string.

Parameters

NameDirectionDescription
jin,outThe target string to append to.
iinInteger value.

Usage example (from documentation)

  JW_INT(json, 42);

Success

Appends a numeric value to json

Failure

Does not return on failure

Usage example (Cross-references)

    }                                                                                                              \
    StrAppendf(&(j), "\"%s\":", k);                                                                                \
    JW_INT(j, i);                                                                                                  \
    } while (0)
    
    JW_OBJ(json, {
    JW_ARR_KV(json, "numbers", empty_numbers, num, { JW_INT(json, num); });
    JW_ARR_KV(json, "strings", empty_strings, str, { JW_STR(json, str); });
    });
    }
    );
    JW_ARR_KV(json, "list", empty_list, item, { JW_INT(json, item); });
    JW_OBJ_KV(json, "deep", {
    JW_OBJ_KV(
    );
    JW_OBJ_KV(json, "filled_obj", { JW_INT_KV(json, "x", x_value); });
    JW_ARR_KV(json, "empty_arr", empty_arr, item, { JW_INT(json, item); });
    JW_ARR_KV(json, "filled_arr", filled_arr, item, { JW_INT(json, item); });
    });
    JW_OBJ_KV(json, "filled_obj", { JW_INT_KV(json, "x", x_value); });
    JW_ARR_KV(json, "empty_arr", empty_arr, item, { JW_INT(json, item); });
    JW_ARR_KV(json, "filled_arr", filled_arr, item, { JW_INT(json, item); });
    });
    
    JW_OBJ(json, {
    JW_ARR_KV(json, "numbers", numbers, num, { JW_INT(json, num); });
    JW_ARR_KV(json, "strings", strings, str, { JW_STR(json, str); });
    JW_ARR_KV(json, "booleans", booleans, b, { JW_BOOL(json, b); });
    Str json = StrInit();
    JW_OBJ(json, {
    JW_ARR_KV(json, "numbers", original_numbers, num, { JW_INT(json, num); });
    JW_ARR_KV(json, "strings", original_strings, str, { JW_STR(json, str); });
    });
    JW_ARR_KV(json, "features", original.config.features, feature, { JW_STR(json, feature); });
    });
    JW_ARR_KV(json, "numbers", original.numbers, num, { JW_INT(json, num); });
    JW_ARR_KV(json, "flags", original.flags, flag, { JW_BOOL(json, flag); });
    });
    JW_OBJ(json, {
    JW_STR_KV(json, "empty_string", empty_str);
    JW_ARR_KV(json, "empty_numbers", empty_numbers, num, { JW_INT(json, num); });
    JW_ARR_KV(json, "empty_strings", empty_strings, str, { JW_STR(json, str); });
    JW_OBJ_KV(

Share :

Related Posts

JR_INT_KV

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

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

JR_ARR_KV

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

Read More