Function create_bms_table_from_json

Source
pub fn create_bms_table_from_json(
    header_url: &str,
    header_json: Value,
    data_json: Value,
) -> Result<BmsTable>
Expand description

从header的绝对URL地址、header和data的JSON解析树创建BmsTable对象

§参数

  • header_url - header文件的绝对URL地址
  • header_json - header的JSON解析树
  • data_json - data的JSON解析树

§返回值

返回解析后的BmsTable对象

§错误

如果JSON解析失败或URL解析失败,将返回错误

§示例

use bms_table::{create_bms_table_from_json, BmsTable};
use serde_json::json;
use url::Url;

#[tokio::main]
#[cfg(feature = "reqwest")]
async fn main() -> anyhow::Result<()> {
    let header_url = "https://example.com/header.json";
    let header_json = json!({
        "name": "Test Table",
        "symbol": "test",
        "data_url": "score.json",
        "course": []
    });
    let data_json = json!([]);
     
    let bms_table = create_bms_table_from_json(header_url, header_json, data_json)?;
    println!("表格名称: {}", bms_table.name);
    Ok(())
}

#[cfg(not(feature = "reqwest"))]
fn main() {}