MCPcopy Create free account
hub / github.com/dprint/jsonc-parser / scan_object_key

Method scan_object_key

src/parser.rs:210–235  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

208 }
209
210 fn scan_object_key(&mut self) -> Result<Option<ObjectKey<'a>>, ParseError> {
211 match self.scan()? {
212 Some(Token::CloseBrace) => Ok(None),
213 Some(Token::String(s)) => Ok(Some(ObjectKey::String(s))),
214 Some(Token::Word(s) | Token::Number(s)) => {
215 if !self.allow_loose_object_property_names {
216 return Err(
217 self
218 .scanner
219 .create_error_for_current_token(ParseErrorKind::ExpectedStringObjectProperty),
220 );
221 }
222 Ok(Some(ObjectKey::Word(s)))
223 }
224 None => Err(
225 self
226 .scanner
227 .create_error_for_current_token(ParseErrorKind::UnterminatedObject),
228 ),
229 _ => Err(
230 self
231 .scanner
232 .create_error_for_current_token(ParseErrorKind::UnexpectedTokenInObject),
233 ),
234 }
235 }
236}

Callers 1

scan_object_entryMethod · 0.80

Calls 2

scanMethod · 0.45

Tested by

no test coverage detected