Skip to main content

parse_object_literal

Function parse_object_literal 

Source
pub fn parse_object_literal(
    s: &str,
) -> Option<Result<HashMap<String, Value>, SqlError>>
Expand description

Parse a { key: value, ... } object literal at the START of s.

This is a PREFIX parser and stops at the matching }. Anything after that brace is left unexamined, deliberately: the function-argument rewriter (preprocess::function_args) hands it the entire remainder of an argument list starting at { and resumes from the matching brace itself, so it needs a parser that reads one literal and stops.

That tolerance is exactly wrong for a caller whose input is supposed to BE the literal — there, unexamined trailing text is input the caller wrote and the parser threw away without saying so. Those callers use parse_object_literal_complete, which reports the leftover instead.

Returns None if the input doesn’t start with { (not an object literal). Returns Some(Err(msg)) on parse errors (malformed object literal). Returns Some(Ok(fields)) on success.