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

Function json_str_array

src/pipeline/pass_semantic_edges.c:340–370  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 3

build_type_vecFunction · 0.85
build_deco_vecFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected