MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / parse_value

Method parse_value

claw-code/rust/crates/runtime/src/json.rs:161–174  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

159 }
160
161 fn parse_value(&mut self) -> Result<JsonValue, JsonError> {
162 self.skip_whitespace();
163 match self.peek() {
164 Some('n') => self.parse_literal("null", JsonValue::Null),
165 Some('t') => self.parse_literal("true", JsonValue::Bool(true)),
166 Some('f') => self.parse_literal("false", JsonValue::Bool(false)),
167 Some('"') => self.parse_string().map(JsonValue::String),
168 Some('[') => self.parse_array(),
169 Some('{') => self.parse_object(),
170 Some('-' | '0'..='9') => self.parse_number().map(JsonValue::Number),
171 Some(other) => Err(JsonError::new(format!("unexpected character: {other}"))),
172 None => Err(JsonError::new("unexpected end of input")),
173 }
174 }
175
176 fn parse_literal(&mut self, expected: &str, value: JsonValue) -> Result<JsonValue, JsonError> {
177 for expected_char in expected.chars() {

Callers 3

parseMethod · 0.80
parse_arrayMethod · 0.80
parse_objectMethod · 0.80

Calls 7

skip_whitespaceMethod · 0.80
peekMethod · 0.80
parse_literalMethod · 0.80
parse_stringMethod · 0.80
parse_arrayMethod · 0.80
parse_objectMethod · 0.80
parse_numberMethod · 0.80

Tested by

no test coverage detected