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

Function json_tree_object_table

src/mcp/compact_out.c:1055–1092  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1053 int depth);
1054
1055static void json_tree_object_table(cbm_sb_t *sb, const char *key_name, size_t key_len,
1056 yyjson_val *array, yyjson_val *first, int depth) {
1057 if (!sb || !key_name || !array || !first) {
1058 return;
1059 }
1060 json_tree_indent(sb, depth);
1061 append_key_n(sb, key_name, key_len);
1062 char count[48];
1063 snprintf(count, sizeof(count), ": %zu (cols:", yyjson_arr_size(array));
1064 cbm_sb_append(sb, count);
1065
1066 size_t key_index;
1067 size_t key_maximum;
1068 yyjson_val *column;
1069 yyjson_val *unused;
1070 yyjson_obj_foreach(first, key_index, key_maximum, column, unused) {
1071 cbm_sb_append_n(sb, " ", 1);
1072 append_key_n(sb, yyjson_get_str(column), yyjson_get_len(column));
1073 }
1074 cbm_sb_append_n(sb, ")\n", 2);
1075
1076 size_t row_index;
1077 size_t row_maximum;
1078 yyjson_val *row;
1079 yyjson_arr_foreach(array, row_index, row_maximum, row) {
1080 json_tree_indent(sb, depth + 1);
1081 bool first_cell = true;
1082 yyjson_obj_foreach(first, key_index, key_maximum, column, unused) {
1083 if (!first_cell) {
1084 cbm_sb_append_n(sb, " ", 1);
1085 }
1086 yyjson_val *cell = yyjson_obj_getn(row, yyjson_get_str(column), yyjson_get_len(column));
1087 json_tree_scalar(sb, cell);
1088 first_cell = false;
1089 }
1090 cbm_sb_append_n(sb, "\n", 1);
1091 }
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) {

Callers 1

json_tree_arrayFunction · 0.85

Calls 5

json_tree_indentFunction · 0.85
append_key_nFunction · 0.85
cbm_sb_appendFunction · 0.85
cbm_sb_append_nFunction · 0.85
json_tree_scalarFunction · 0.85

Tested by

no test coverage detected