Skip to main content

from_json

Function from_json 

Source
pub fn from_json<T: DeserializeOwned>(text: &str) -> Result<T>
Expand description

What JSON text holds, read as T: a scene, a camera, a fit, a query, rows, a budget, a shot, or any type that deserializes. An error names the path to what could not be read.

let scene: latkit::Scene = latkit::from_json(r#"{"space": "plane", "marks": []}"#)?;
let error = latkit::from_json::<latkit::Scene>(r#"{"space": "plane", "marks": [{"vertices": 3}]}"#);
assert!(error.unwrap_err().to_string().starts_with("marks[0]"));