json-read 1.0.1

json-read是一个json读取工具,可以直接通过`x.y.z.w`方式读取json中的内容,不用逐层解析
Documentation
  • Coverage
  • 54.55%
    6 out of 11 items documented1 out of 9 items with examples
  • Size
  • Source code size: 14.55 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 392.76 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 18s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Documentation
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • TheoryDance

json-read

介绍

json-read是一个json读取工具,可以直接通过x.y.z.w方式读取json中的内容,不用逐层解析

使用示例

use json_read::JsonWrapper;

#[test]
fn test_config_util() {
    let wrapper = JsonWrapper::new("docs/config.json").unwrap(); // json配置
    // let warpper = JsonWrapper::from_string("......").unwrap();

    // 注意: 这里面的children是一个数组,不管是数组还是对象,都是通过点来操作
    let x = wrapper.get("address.children.name");
    // address.children.name = [String("r"), String("s")]
    println!("address.children.name = {:?}", x);
    println!("=============================================================");

    // 作为配置使用,正常是知晓需要
    let x = wrapper.get_one("address.x.y").as_str().unwrap();
    // address.x.y = hello, json!
    println!("address.x.y = {}", x);
}

安装教程

cargo add json-read