ribo 0.1.3

Ribo for universe, provide tons of util functions.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::{fs::File, io::Read};

use serde_json::Value;

pub fn load_json_file(path: &str) -> Result<Value, String> {
    let file = File::open(path);
    if file.is_err() {
        return Err(format!("failed to open file: {}", file.err().unwrap()));
    }

    let mut data = String::new();
    file.unwrap()
        .read_to_string(&mut data)
        .map_err(|e| e.to_string())?;
    let json_value: Value = serde_json::from_str(&data).map_err(|e| e.to_string())?;

    Ok(json_value)
}