pub fn from_value(value: Value) -> Result<Feed, Error>
Expand description

Attempts to return a Feed from a JSON Value.

Errors

If the JSON value is not an Object, then Error::UnexpectedType is returned.

Example

If the library user wishes to save invalid JSON values, a simple check should be done before calling the function.

let value = serde_json::json!("a JSON String, not an Object");
match &value {
    serde_json::Value::Object(_) => {
        let feed_result = json_feed_model::from_value(value);
        assert!(false, "should not have execute this code")
    }
    _ => {
        // handle the invalid JSON value
    },
}