| 1053 | int depth); |
| 1054 | |
| 1055 | static 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 | |
| 1094 | static void json_tree_array(cbm_sb_t *sb, const char *key_name, size_t key_len, yyjson_val *array, |
| 1095 | int depth) { |
no test coverage detected