just add data loader here
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Has been cancelled
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Has been cancelled
This commit is contained in:
parent
04ae29eb27
commit
55df6bdb16
23 changed files with 4097 additions and 1 deletions
31
data_loader/src/septa_json/route_stop.rs
Normal file
31
data_loader/src/septa_json/route_stop.rs
Normal 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> {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue