core_api_client 1.1.0

A Rust library for interacting with CORE API, a service that provides access to metadata and full texts of research papers from thousands of data providers.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use serde::{Deserializer, Deserialize};

/// Custom deserialization function that always deserializes as a string
pub(crate) fn deserialize_as_string<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
where
    D: Deserializer<'de>,
{
    let opt = Option::deserialize(deserializer)?;
    match opt {
        Some(serde_json::Value::Number(n)) => Ok(Some(n.to_string())),
        Some(serde_json::Value::String(s)) => Ok(Some(s)),
        _ => Ok(None),
    }
}