neosqlite.collection.json_path_utils module¶
Shared utility module for JSON path parsing functionality.
This module provides common JSON path parsing functions to avoid code duplication across multiple modules. It handles conversion of dot notation with optional array indexing to JSON path syntax.
- neosqlite.collection.json_path_utils.parse_json_path(field: str) str[source]¶
Convert dot notation with array indexing to JSON path syntax.
Supports: - Simple fields: “name” -> “$.name” - Nested fields: “address.street” -> “$.address.street” - Array indexing: “tags[0]” -> “$.tags[0]” - Nested array access: “orders.items[2].name” -> “$.orders.items[2].name” - Complex paths: “a.b[0].c[1].d” -> “$.a.b[0].c[1].d”
- Parameters:
field (str) – The field path in dot notation with optional array indices
- Returns:
Properly formatted JSON path
- Return type:
str
- neosqlite.collection.json_path_utils.build_json_extract_expression(data_column: str, field_path: str) str[source]¶
Build a complete json_extract SQL expression with properly formatted JSON path.
- Parameters:
data_column (str) – The name of the JSON data column (e.g., “data”)
field_path (str) – The field path in dot notation (e.g., “name”, “address.street[0]”)
- Returns:
Complete json_extract expression, e.g., “json_extract(data, ‘$.field’)”
- Return type:
str
- neosqlite.collection.json_path_utils.build_jsonb_extract_expression(data_column: str, field_path: str) str[source]¶
Build a complete jsonb_extract SQL expression with properly formatted JSON path.
- Parameters:
data_column (str) – The name of the JSON data column (e.g., “data”)
field_path (str) – The field path in dot notation (e.g., “name”, “address.street[0]”)
- Returns:
Complete jsonb_extract expression, e.g., “jsonb_extract(data, ‘$.field’)”
- Return type:
str