16 releases

new 0.3.6 May 12, 2024
0.3.5 Apr 30, 2024
0.2.2 Mar 25, 2024
0.1.5 Mar 9, 2024
0.1.3 Feb 19, 2024

#2363 in Parser implementations

Download history 178/week @ 2024-02-12 222/week @ 2024-02-19 2/week @ 2024-02-26 261/week @ 2024-03-04 59/week @ 2024-03-11 329/week @ 2024-03-18 123/week @ 2024-03-25 479/week @ 2024-04-01 8/week @ 2024-04-08 337/week @ 2024-04-29

359 downloads per month

AGPL-3.0-or-later

22KB
490 lines

rsjson

  • Json file parser library

crates.io repository

docs.rs documentation


Installation

  • add to your Cargo.toml:
...
[dependencies]
rsjson = "0.3.6"
  • or run the following command in terminal:
cargo add rsjson

Importation

  • include the following line into your code
use rsjson;

lib.rs:

Json file parser library

Installation

...
[dependencies]
rsjson = "0.3.6";

or run

cargo add rsjson

Importation

use rsjson;

Code example

  • read and parse a json file
let json: Result<rsjson::Json, String> = rsjson::Json::fromFile("/path/to/file.json");
  • read and parse a json structure from a string
let json: Result<rsjson::Json, String> = rsjson::Json::fromString("{\"key\":\"value\"}");
  • in both previous cases, remeber to handle the eventual error (e.g. using match) or to call unwrap()

  • create an empty json instance

let json = rsjson::Json::new();
  • add a node
json.addNode(
    rsjson::Node::new(
        "nodeLabel",
        rsjson::NodeContent::Int(32)
    )
);
  • edit a node's label
json.editNode(
    "nodeLabel",
    "newNodeLabel"
);
  • edit a node's content
json.editContent(
    "nodeLabel",
    rsjson::NodeContent::Bool(true)
);
  • remove a node
json.removeNode(
    "nodeLabel"
);

No runtime deps