1 2 3 4 5 6 7 8 9
use serde_json::Value; pub fn to_array(json: &Value) -> Result<Vec<Value>, String> { match json.as_array() { Some(results) => Ok(results.to_vec()), None => Err(format!("JSON value is not an array: {:#?}", json)) } }