MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / parse_object_literal

Function parse_object_literal

nodedb-sql/src/parser/object_literal.rs:16–24  ·  view source on GitHub ↗

Parse a `{ key: value, ... }` object literal into a field map. 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.

(s: &str)

Source from the content-addressed store, hash-verified

14/// Returns `Some(Err(msg))` on parse errors (malformed object literal).
15/// Returns `Some(Ok(fields))` on success.
16pub fn parse_object_literal(s: &str) -> Option<Result<HashMap<String, Value>, SqlError>> {
17 let trimmed = s.trim();
18 if !trimmed.starts_with('{') {
19 return None;
20 }
21 let chars: Vec<char> = trimmed.chars().collect();
22 let mut pos = 0;
23 Some(parse_object(&chars, &mut pos))
24}
25
26/// Parse `[{ ... }, { ... }]` — an array of object literals for batch insert.
27///

Callers 7

plan_sliceFunction · 0.85
parseFunction · 0.85
missing_key_returns_errFunction · 0.85
properties_to_jsonFunction · 0.85

Calls 2

parse_objectFunction · 0.85
collectMethod · 0.80

Tested by 2

missing_key_returns_errFunction · 0.68