MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / json_tree_array

Function json_tree_array

src/mcp/compact_out.c:1094–1131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1092}
1093
1094static void json_tree_array(cbm_sb_t *sb, const char *key_name, size_t key_len, yyjson_val *array,
1095 int depth) {
1096 yyjson_val *first = NULL;
1097 if (json_tree_array_is_object_table(array, &first)) {
1098 json_tree_object_table(sb, key_name, key_len, array, first, depth);
1099 return;
1100 }
1101
1102 json_tree_indent(sb, depth);
1103 append_key_n(sb, key_name, key_len);
1104 char count[48];
1105 snprintf(count, sizeof(count), ": %zu\n", yyjson_arr_size(array));
1106 cbm_sb_append(sb, count);
1107 size_t index;
1108 size_t maximum;
1109 yyjson_val *item;
1110 yyjson_arr_foreach(array, index, maximum, item) {
1111 if (yyjson_is_obj(item)) {
1112 json_tree_indent(sb, depth + 1);
1113 cbm_sb_append(sb, "-\n");
1114 size_t field_index;
1115 size_t field_maximum;
1116 yyjson_val *field;
1117 yyjson_val *field_value;
1118 yyjson_obj_foreach(item, field_index, field_maximum, field, field_value) {
1119 json_tree_value(sb, yyjson_get_str(field), yyjson_get_len(field), field_value,
1120 depth + 2);
1121 }
1122 } else if (yyjson_is_arr(item)) {
1123 json_tree_value(sb, "-", 1, item, depth + 1);
1124 } else {
1125 json_tree_indent(sb, depth + 1);
1126 cbm_sb_append(sb, "- ");
1127 json_tree_scalar(sb, item);
1128 cbm_sb_append_n(sb, "\n", 1);
1129 }
1130 }
1131}
1132
1133static void json_tree_value(cbm_sb_t *sb, const char *key_name, size_t key_len, yyjson_val *value,
1134 int depth) {

Callers 2

json_tree_valueFunction · 0.85
cbm_json_to_treeFunction · 0.85

Calls 8

json_tree_object_tableFunction · 0.85
json_tree_indentFunction · 0.85
append_key_nFunction · 0.85
cbm_sb_appendFunction · 0.85
json_tree_valueFunction · 0.85
json_tree_scalarFunction · 0.85
cbm_sb_append_nFunction · 0.85

Tested by

no test coverage detected