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

Function json_str_array

src/pipeline/pass_semantic_edges.c:339–369  ·  view source on GitHub ↗

Extract a JSON array of strings by key. Returns count. */

Source from the content-addressed store, hash-verified

337
338/* Extract a JSON array of strings by key. Returns count. */
339static int json_str_array(const char *json, const char *key, char **out, int max_out) {
340 if (!json || !key) {
341 return 0;
342 }
343 char search[CBM_SZ_64];
344 snprintf(search, sizeof(search), "\"%s\":[", key);
345 const char *start = strstr(json, search);
346 if (!start) {
347 return 0;
348 }
349 start += strlen(search);
350 int count = 0;
351 while (*start && *start != ']' && count < max_out) {
352 if (*start == '"') {
353 start++;
354 const char *end = strchr(start, '"');
355 if (!end) {
356 break;
357 }
358 int len = (int)(end - start);
359 out[count] = cbm_alloc(CBM_MEM_CLASS_SEMANTIC, (size_t)len + SKIP_ONE);
360 memcpy(out[count], start, (size_t)len);
361 out[count][len] = '\0';
362 count++;
363 start = end + SKIP_ONE;
364 } else {
365 start++;
366 }
367 }
368 return count;
369}
370
371/* ── Tokenize node metadata ──────────────────────────────────────── */
372

Callers 3

build_type_vecFunction · 0.85
build_deco_vecFunction · 0.85

Calls 1

cbm_allocFunction · 0.85

Tested by

no test coverage detected