pub(crate) fn parse_path(
s: &str,
) -> Result<Vec<VariantPathElement<'_>>, ArrowError>Expand description
Parse a path string into a vector of VariantPathElement.
§Syntax
.fieldorfield- access object field (do not support special char)[index]- access array element by index[field]- access object field (support special char with escape\)
§Escape Rules
Inside brackets [...]:
\\-> literal\\]-> literal]- Any other
\x-> literalx
Outside brackets, no escaping is supported.
§Examples
""-> empty path"foo"-> single fieldfoo"foo.bar"-> nested fieldsfoo,bar"[1]"-> array index 1"foo[1].bar"-> fieldfoo, index 1, fieldbar"[a.b]"-> fielda.b(dot is literal inside bracket)"[a\\]b]"-> fielda]b(escaped]- etc.
§Errors
- Leading
.(e.g.,".foo") - Trailing
.(e.g.,"foo.") - Unclosed ‘[’ (e.g.,
"foo[1") - Unexpected ‘]’ (e.g.,
"foo]") - Trailing ‘`’ inside bracket (treated as unclosed bracket)