#serde-json #json #serde

merge-struct

可序列化结构的深度合并

1个不稳定版本

0.1.0 2022年8月8日

#1049编码

Download history 169/week @ 2024-03-13 293/week @ 2024-03-20 258/week @ 2024-03-27 143/week @ 2024-04-03 122/week @ 2024-04-10 187/week @ 2024-04-17 204/week @ 2024-04-24 184/week @ 2024-05-01 148/week @ 2024-05-08 209/week @ 2024-05-15 538/week @ 2024-05-22 309/week @ 2024-05-29 259/week @ 2024-06-05 155/week @ 2024-06-12 149/week @ 2024-06-19 129/week @ 2024-06-26

753 每月下载量
5 crates 中使用

Apache-2.0

10KB
166

合并结构体

github crates.io docs.rs build status

这是一个Rust库,用于深度合并两个可序列化结构体。

依赖项

[dependencies]
merge-struct = "0.1.0"

查看最新版本请见 crates.io

使用方法

use std::collections::BTreeMap;
use serde_json;
use serde::{Deserialize, Serialize};
use merge_struct::merge;

let left: Data = serde_json::from_str(
    r###"
{
    "is_root": false,
    "entries": {
        "/var/log/f2": {
            "name":"f2",
            "size": 5
        }
    },
    "folders": [
        {
            "name": "/var/log",
            "num_files": 20
        }
    ]
}
"###,
)
.unwrap();

let right: Data = serde_json::from_str(
    r###"
{
    "folders":[],
    "entries": {
        "/var/log/f1": {
            "name":"f1",
            "size": 12
        }
    }
}
"###,
).unwrap();

let res = merge(&left, &right);

版权

版权(c)2022 @jondot。有关详细信息,请参阅 LICENSE

依赖项

~355–760KB
~17K SLoC