pub fn file_json_field<T: DeserializeOwned>(
json_file_path: &Path,
field_name: &str,
) -> Result<T>
Expand description
Reads a JSON file, extracts a specific field, and deserializes it into type T.
§Arguments
json_file_path
: Path to the JSON file.field_name
: The name of the field to extract from the JSON map.
§Returns
A Result
containing the deserialized value of type T
if successful,
or an anyhow::Error
if any step fails (file I/O, JSON parsing, field not found,
or deserialization to T
fails).
§Type Parameters
T
: The expected type of the field’s value.T
must implementserde::de::DeserializeOwned
.