mirror of
https://github.com/NexVeridian/wikidata-to-surrealdb.git
synced 2025-09-02 09:59:13 +00:00
mulit line json
This commit is contained in:
parent
b838a5c326
commit
f0716081fe
3 changed files with 27 additions and 19 deletions
12
src/utils.rs
12
src/utils.rs
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue