Extract a string property from a properties JSON string. * Returns heap-allocated string or NULL. Caller must free. * Parses real JSON: the dump writer feeds these values into indexes whose * backing columns are GENERATED AS json_extract(properties,'$. '). * Naive byte slicing returned the ESCAPED text (and cut at embedded \\") * while json_extract yields the unescaped value — the mismatc
| 1373 | * "missing from index idx_edges_url_path" under PRAGMA integrity_check. |
| 1374 | * key_quoted ("\"key\"") is a fast pre-filter to skip the JSON parse. */ |
| 1375 | static char *extract_prop_string(const char *props, const char *key_quoted, const char *key) { |
| 1376 | if (!props || !strstr(props, key_quoted)) { |
| 1377 | return NULL; |
| 1378 | } |
| 1379 | yyjson_doc *doc = yyjson_read(props, strlen(props), 0); |
| 1380 | if (!doc) { |
| 1381 | return NULL; |
| 1382 | } |
| 1383 | char *out = NULL; |
| 1384 | yyjson_val *v = yyjson_obj_get(yyjson_doc_get_root(doc), key); |
| 1385 | if (v && yyjson_is_str(v)) { |
| 1386 | const char *sv = yyjson_get_str(v); |
| 1387 | out = cbm_strndup(sv, strlen(sv)); |
| 1388 | } |
| 1389 | yyjson_doc_free(doc); |
| 1390 | return out; |
| 1391 | } |
| 1392 | |
| 1393 | static char *extract_url_path(const char *props) { |
| 1394 | return extract_prop_string(props, "\"url_path\"", "url_path"); |
no test coverage detected