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
| 2242 | * "missing from index idx_edges_url_path" under PRAGMA integrity_check. |
| 2243 | * key_quoted ("\"key\"") is a fast pre-filter to skip the JSON parse. */ |
| 2244 | static char *extract_prop_string(const char *props, const char *key_quoted, const char *key) { |
| 2245 | if (!props || !strstr(props, key_quoted)) { |
| 2246 | return NULL; |
| 2247 | } |
| 2248 | yyjson_doc *doc = yyjson_read(props, strlen(props), 0); |
| 2249 | if (!doc) { |
| 2250 | return NULL; |
| 2251 | } |
| 2252 | char *out = NULL; |
| 2253 | yyjson_val *v = yyjson_obj_get(yyjson_doc_get_root(doc), key); |
| 2254 | if (v && yyjson_is_str(v)) { |
| 2255 | const char *sv = yyjson_get_str(v); |
| 2256 | out = cbm_mem_strdup(CBM_MEM_CLASS_DUMP, sv); |
| 2257 | } |
| 2258 | yyjson_doc_free(doc); |
| 2259 | return out; |
| 2260 | } |
| 2261 | |
| 2262 | static char *extract_url_path(const char *props) { |
| 2263 | return extract_prop_string(props, "\"url_path\"", "url_path"); |
no test coverage detected