13 releases

0.3.3 Apr 2, 2024
0.3.2 Apr 2, 2024
0.2.2 Mar 25, 2024
0.1.5 Mar 9, 2024
0.1.3 Feb 19, 2024

#2182 in Parser implementations

Download history 121/week @ 2024-02-10 270/week @ 2024-02-17 11/week @ 2024-02-24 143/week @ 2024-03-02 158/week @ 2024-03-09 317/week @ 2024-03-16 146/week @ 2024-03-23 459/week @ 2024-03-30 35/week @ 2024-04-06 1/week @ 2024-04-13

650 downloads per month

AGPL-3.0-or-later

22KB
487 lines

rsjson

  • Json file parser library

crates.io repository

docs.rs documentation


Installation

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

Importation

  • include the following line to your code
use rsjson;

lib.rs:

Json file parser library

Installation

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

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