just add data loader here
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Has been cancelled

This commit is contained in:
Nicholas Orlowsky 2025-09-12 19:34:35 -04:00
parent 04ae29eb27
commit 55df6bdb16
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B
23 changed files with 4097 additions and 1 deletions

View file

@ -0,0 +1,31 @@
use crate::traits::*;
use serde::{self, Deserialize, Deserializer};
pub fn de_string_or_int<'de, D>(deserializer: D) -> Result<i64, D::Error>
where
D: Deserializer<'de>,
{
use serde::de::Error;
use serde_json::Value;
match Value::deserialize(deserializer)? {
Value::Number(n) => n.as_i64().ok_or_else(|| Error::custom("Invalid number")),
Value::String(s) => s.parse::<i64>().map_err(|_| Error::custom("Invalid string number")),
_ => Err(Error::custom("Expected a string or number")),
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct RouteStop {
pub route_id: String,
pub direction_id: i64,
#[serde(deserialize_with = "de_string_or_int")]
pub stop_id: i64,
pub stop_name: String,
pub stop_sequence: i64,
pub stop_lat: f64,
pub stop_lon: f64,
}
impl SeptaJson for RouteStop {}
impl SeptaJson for Vec<RouteStop> {}