Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,19 @@ impl JsonValue {
}
}

/// Works on `JsonValue::Array` - insert an entry at index.
/// will return error not on `JsonValue::Array`.
pub fn array_insert<T>(&mut self, index: usize, value: T) -> Result<()>
where T: Into<JsonValue> {
match *self {
JsonValue::Array(ref mut vec) => {
vec.insert(index, value.into());
Ok(())
},
_ => Err(Error::wrong_type("I'snt an Arry"))
}
}

/// When called on an array or an object, will wipe them clean. When called
/// on a string will clear the string. Numbers and booleans become null.
pub fn clear(&mut self) {
Expand Down