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
| 1423 | * "missing from index idx_edges_url_path" under PRAGMA integrity_check. |
| 1424 | * key_quoted ("\"key\"") is a fast pre-filter to skip the JSON parse. */ |
| 1425 | static char *extract_prop_string(const char *props, const char *key_quoted, const char *key) { |
| 1426 | if (!props || !strstr(props, key_quoted)) { |
| 1427 | return NULL; |
| 1428 | } |
| 1429 | yyjson_doc *doc = yyjson_read(props, strlen(props), 0); |
| 1430 | if (!doc) { |
| 1431 | return NULL; |
| 1432 | } |
| 1433 | char *out = NULL; |
| 1434 | yyjson_val *v = yyjson_obj_get(yyjson_doc_get_root(doc), key); |
| 1435 | if (v && yyjson_is_str(v)) { |
| 1436 | const char *sv = yyjson_get_str(v); |
| 1437 | out = cbm_strndup(sv, strlen(sv)); |
| 1438 | } |
| 1439 | yyjson_doc_free(doc); |
| 1440 | return out; |
| 1441 | } |
| 1442 | |
| 1443 | static char *extract_url_path(const char *props) { |
| 1444 | return extract_prop_string(props, "\"url_path\"", "url_path"); |
no test coverage detected