Skip to content

Commit 298e09a

Browse files
authored
Merge pull request #95 from maciejhirsz/state_machine
0.11.0 closes #93 #96
2 parents feb364a + 18d367d commit 298e09a

File tree

6 files changed

+223
-196
lines changed

6 files changed

+223
-196
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "json"
3-
version = "0.10.3"
3+
version = "0.11.0"
44
authors = ["Maciej Hirsz <maciej.hirsz@gmail.com>"]
55
description = "JSON implementation in Rust"
66
repository = "https://github.com/maciejhirsz/json-rust"

src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub enum Error {
1313
column: usize,
1414
},
1515
UnexpectedEndOfJson,
16+
ExceededDepthLimit,
1617
FailedUtf8Parsing,
1718
WrongType(String),
1819
}
@@ -35,6 +36,7 @@ impl fmt::Display for Error {
3536
} => write!(f, "Unexpected character: {} at ({}:{})", ch, line, column),
3637

3738
UnexpectedEndOfJson => write!(f, "Unexpected end of JSON"),
39+
ExceededDepthLimit => write!(f, "Exceeded depth limit"),
3840
FailedUtf8Parsing => write!(f, "Failed to parse UTF-8 bytes"),
3941
WrongType(ref s) => write!(f, "Wrong type, expected: {}", s),
4042
}
@@ -44,9 +46,11 @@ impl fmt::Display for Error {
4446
impl error::Error for Error {
4547
fn description(&self) -> &str {
4648
use Error::*;
49+
4750
match *self {
4851
UnexpectedCharacter { .. } => "Unexpected character",
4952
UnexpectedEndOfJson => "Unexpected end of JSON",
53+
ExceededDepthLimit => "Exceeded depth limit",
5054
FailedUtf8Parsing => "Failed to read bytes as UTF-8 from JSON",
5155
WrongType(_) => "Wrong type",
5256
}

src/object.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,13 @@ impl Object {
339339
}
340340
}
341341

342+
#[inline]
343+
pub fn override_last(&mut self, value: JsonValue) {
344+
if let Some(node) = self.store.last_mut() {
345+
node.value = value;
346+
}
347+
}
348+
342349
pub fn get(&self, key: &str) -> Option<&JsonValue> {
343350
if self.store.len() == 0 {
344351
return None;

0 commit comments

Comments
 (0)