Append `,"key":" "` for a string member, or nothing when the * member is absent or not a string (required ones are written empty). */
| 859 | /* Append `,"key":"<escaped value>"` for a string member, or nothing when the |
| 860 | * member is absent or not a string (required ones are written empty). */ |
| 861 | static void ui_log_add_str(ui_log_scratch_t *s, int *pos, const char *key, yyjson_val *v, |
| 862 | bool required) { |
| 863 | if (!v || !yyjson_is_str(v)) { |
| 864 | if (required) |
| 865 | http_appendf(s->line, sizeof(s->line), pos, ",\"%s\":\"\"", key); |
| 866 | return; |
| 867 | } |
| 868 | ui_log_copy_field(s->field, sizeof(s->field), yyjson_get_str(v), UI_LOG_FIELD_MAX); |
| 869 | cbm_json_escape(s->esc, (int)sizeof(s->esc), s->field); |
| 870 | http_appendf(s->line, sizeof(s->line), pos, ",\"%s\":\"%s\"", key, s->esc); |
| 871 | } |
| 872 | |
| 873 | static void ui_log_add_int(ui_log_scratch_t *s, int *pos, const char *key, yyjson_val *v) { |
| 874 | if (!v || !yyjson_is_num(v)) |
no test coverage detected