Extract a JSON array of strings by key. Returns count. */
| 338 | |
| 339 | /* Extract a JSON array of strings by key. Returns count. */ |
| 340 | static 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 |
no outgoing calls
no test coverage detected