pub fn append_to_array(
json: &mut Vec<u8>,
path: &[PathSegment<'_>],
new_element: &[u8],
) -> Result<(), Error>Expand description
Appends a new value to the end of a JSON array located at the specified path.
If the array is currently empty, the value is written directly. If it contains elements, a separating comma is injected before the new value.
§Examples
use jshift::{append_to_array, parse_path};
let mut json = b"{\"list\": [10, 20]}".to_vec();
append_to_array(&mut json, &parse_path("list"), b"30").unwrap();
assert_eq!(json, b"{\"list\": [10, 20,30]}".to_vec());