mulit line json

This commit is contained in:
Elijah McMorris 2023-12-13 15:20:48 -08:00
parent b838a5c326
commit f0716081fe
Signed by: NexVeridian
SSH key fingerprint: SHA256:bsA1SKZxuEcEVHAy3gY1HUeM5ykRJl0U0kQHQn0hMg8
3 changed files with 27 additions and 19 deletions

View file

@ -1,20 +1,8 @@
use anyhow::{Error, Result};
use serde::{Deserialize, Serialize};
use serde_json::from_reader;
use serde_json::Value;
use std::fs::File;
use surrealdb::sql::Thing;
use wikidata::ClaimValueData;
use wikidata::{ClaimValue, Entity, Lang, Pid, WikiId};
pub async fn get_entity(path: &str) -> Result<Entity, Error> {
// From here - https://www.wikidata.org/wiki/Special:EntityData/P1476.json
let mut file = File::open(path)?;
let json: Value = from_reader(&mut file)?;
let data = Entity::from_json(json).expect("Failed to parse JSON");
Ok(data)
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EntityMini {
// In English