serde-json-utils

Crates.ioserde-json-utils
lib.rsserde-json-utils
version0.2.1
sourcesrc
created_at2022-05-30 04:26:12.875204
updated_at2022-06-09 12:39:59.718481
descriptionUtil crate for serde_json Value
homepagehttps://github.com/marirs/serde-json-utils
repositoryhttps://github.com/marirs/serde-json-utils
max_upload_size
id596785
size20,771
SG (marirs)

documentation

README

serde_json_utils

Linux Arm7 Linux x86_64 macOS intel Windows

Utility functions for serde_json::Value. The functions are implemented as traits so all you need is to add the crate to your dependencies in your Cargo.toml.

Requirements

  • Rust 1.56+

Usage

[dependencies]
serde-json-utils = "0.2.1"

Example

  • To skip null & empty entries from serde_json::Value
const DATA: &str = r###"
    [
        {
            "key1": null,
            "key2": "there is a value",
            "key3": {},
            "key4": [],
            "key5": [1, 2, 3, 3]
        },
        {
            "key1": "value in here",
            "key2": null
        },
        {
            "key1": "value in here",
            "key2": null
        }
    ]
    "###;

fn main() {
    let mut val: Value = from_str(DATA).unwrap();
    val.skip_null_and_empty();
    
    println!("{:#?}", val);
}

License: MIT

Commit count: 23

cargo fmt