| 214 | } |
| 215 | |
| 216 | fn parse_unicode_escape(&mut self) -> Result<char, JsonError> { |
| 217 | let mut value = 0_u32; |
| 218 | for _ in 0..4 { |
| 219 | let Some(ch) = self.next() else { |
| 220 | return Err(JsonError::new("unexpected end of input in unicode escape")); |
| 221 | }; |
| 222 | value = (value << 4) |
| 223 | | ch.to_digit(16) |
| 224 | .ok_or_else(|| JsonError::new("invalid unicode escape"))?; |
| 225 | } |
| 226 | char::from_u32(value).ok_or_else(|| JsonError::new("invalid unicode scalar value")) |
| 227 | } |
| 228 | |
| 229 | fn parse_array(&mut self) -> Result<JsonValue, JsonError> { |
| 230 | self.expect('[')?; |