JW_FLT_KV
- Macro
- August 22, 2025
Table of Contents
JW_FLT_KV
JW_FLT_KV
Description
Write a key and float value to a JSON object.
Parameters
Name | Direction | Description |
---|---|---|
j | in,out | The target string to append to. |
k | in | Key name. |
f | in | Floating-point value. |
Usage example (from documentation)
JW_FLT_KV(json, "pi", 3.14159);
Success
Appends a key-value float pair
Failure
Does not return on failure
Usage example (Cross-references)
JW_OBJ(json, {
JW_INT_KV(json, "count", count);
JW_FLT_KV(json, "score", score);
JW_INT_KV(json, "year", year);
});
JW_INT_KV(json, "age", person.age);
JW_BOOL_KV(json, "is_active", person.is_active);
JW_FLT_KV(json, "salary", person.salary);
});
JW_INT_KV(json, "id", product.id);
JW_STR_KV(json, "name", product.name);
JW_FLT_KV(json, "price", product.price);
JW_ARR_KV(json, "tags", product.tags, tag, { JW_STR(json, tag); });
});
JW_OBJ(json, {
JW_INT_KV(json, "temp", temp);
JW_FLT_KV(json, "balance", balance);
JW_FLT_KV(json, "delta", delta);
});
JW_INT_KV(json, "temp", temp);
JW_FLT_KV(json, "balance", balance);
JW_FLT_KV(json, "delta", delta);
});
JW_OBJ(json, {
JW_INT_KV(json, "big_int", big_int);
JW_FLT_KV(json, "big_float", big_float);
JW_FLT_KV(json, "small_float", small_float);
});
JW_INT_KV(json, "big_int", big_int);
JW_FLT_KV(json, "big_float", big_float);
JW_FLT_KV(json, "small_float", small_float);
});
JW_OBJ(json, {
JW_INT_KV(json, "int_zero", int_zero);
JW_FLT_KV(json, "float_zero", float_zero);
JW_BOOL_KV(json, "bool_false", bool_false);
});
JW_OBJ(json, {
JW_FLT_KV(json, "tiny", tiny);
JW_FLT_KV(json, "huge", huge);
JW_FLT_KV(json, "zero", zero);
JW_OBJ(json, {
JW_FLT_KV(json, "tiny", tiny);
JW_FLT_KV(json, "huge", huge);
JW_FLT_KV(json, "zero", zero);
JW_FLT_KV(json, "negative_tiny", negative_tiny);
JW_FLT_KV(json, "tiny", tiny);
JW_FLT_KV(json, "huge", huge);
JW_FLT_KV(json, "zero", zero);
JW_FLT_KV(json, "negative_tiny", negative_tiny);
});
JW_FLT_KV(json, "huge", huge);
JW_FLT_KV(json, "zero", zero);
JW_FLT_KV(json, "negative_tiny", negative_tiny);
});
// Single float
f64 single_float = 3.14;
JW_OBJ(json4, { JW_FLT_KV(json4, "pi", single_float); });
const char* expected1 = "{\"value\":42}";
JW_STR_KV(json, "head", data.company.departments.engineering.head);
JW_INT_KV(json, "count", data.company.departments.engineering.count);
JW_FLT_KV(json, "budget", data.company.departments.engineering.budget);
});
});
JW_OBJ_KV(json, target_key.data, {
JW_FLT_KV(json, "distance", s->distance);
JW_INT_KV(json, "nearest_neighbor_analysis_id", s->analysis_id);
JW_INT_KV(json, "nearest_neighbor_binary_id", s->binary_id);
JW_OBJ_KV(json, target_key.data, {
JW_FLT_KV(json, "distance", symbol.distance);
JW_STR_KV(json, "name", symbol.function_name);
});
- In
RoundTrip.c:102
:
JW_OBJ(json, {
JW_INT_KV(json, "count", original.count);
JW_FLT_KV(json, "temperature", original.temperature);
JW_BOOL_KV(json, "enabled", original.enabled);
JW_STR_KV(json, "message", original.message);
- In
RoundTrip.c:176
:
JW_INT_KV(json, "negative_int", original.negative_int);
JW_INT_KV(json, "zero_int", original.zero_int);
JW_FLT_KV(json, "precise_float", original.precise_float);
JW_FLT_KV(json, "small_float", original.small_float);
JW_FLT_KV(json, "negative_float", original.negative_float);
- In
RoundTrip.c:177
:
JW_INT_KV(json, "zero_int", original.zero_int);
JW_FLT_KV(json, "precise_float", original.precise_float);
JW_FLT_KV(json, "small_float", original.small_float);
JW_FLT_KV(json, "negative_float", original.negative_float);
});
- In
RoundTrip.c:178
:
JW_FLT_KV(json, "precise_float", original.precise_float);
JW_FLT_KV(json, "small_float", original.small_float);
JW_FLT_KV(json, "negative_float", original.negative_float);
});
- In
RoundTrip.c:465
:
JW_INT_KV(json, "age", original_person.age);
JW_BOOL_KV(json, "is_active", original_person.is_active);
JW_FLT_KV(json, "salary", original_person.salary);
});
});
- In
RoundTrip.c:544
:
JW_INT_KV(json, "age", original.user.age);
JW_BOOL_KV(json, "is_active", original.user.is_active);
JW_FLT_KV(json, "salary", original.user.salary);
});
JW_OBJ_KV(json, "config", {
- In
RoundTrip.c:738
:
JW_INT_KV(json, "min_int", original.min_int);
JW_INT_KV(json, "zero", original.zero);
JW_FLT_KV(json, "zero_float", original.zero_float);
JW_BOOL_KV(json, "true_val", original.true_val);
JW_BOOL_KV(json, "false_val", original.false_val);