#serde-json #json #sorting #merge #serde #iter

serde_json_merge

Merge, index, iterate, and sort a serde_json::Value (recursively)

2 releases

0.0.4 Sep 28, 2022
0.0.3 Sep 22, 2022

#886 in Encoding

Download history 64/week @ 2024-08-16 5/week @ 2024-08-23 6/week @ 2024-08-30 68/week @ 2024-09-13 63/week @ 2024-09-20 51/week @ 2024-09-27 17/week @ 2024-10-04 25/week @ 2024-10-11 76/week @ 2024-10-18 17/week @ 2024-10-25 18/week @ 2024-11-01

137 downloads per month
Used in 2 crates

Custom license

110KB
3K SLoC

serde_json_merge

build status test status benchmarks crates.io docs.rs

Merge, index, iterate, and sort a serde_json::Value (recursively).

This library supports in-place merging and sorting using DFS and BFS traversal unline most implementations out there that use recursion and can stack overflow.

[dependencies]
serde_json_merge = "0"

Usage

For usage examples, check the examples and documentation.

Examples

cargo run --example async_fs --features async -- --path ./
cargo run --example sync_fs --features sync,rayon -- --path ./

Documentation

RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features

Linting

cargo feature-combinations clippy --fail-fast --pedantic --tests --benches --examples -- -Dclippy::all -Dclippy::pedantic
cargo clippy --tests --benches --examples -- -Dclippy::all -Dclippy::pedantic

Benchmarking

cargo install cargo-criterion
# full benchmark suite
cargo criterion --features full

Benchmark reports from CI are published are available here.

Acknowledgements

After i wrote this crate for another project and decided to publish it, I found json_value_merge.

Looking through it, I added merge_index inspired by their merge_in API.

TODO

  • write benchmarks

  • add globbing iter

  • add iters for keys and values

  • implement sorting values with indices

  • implement bfs

  • add rayon support using par-dfs

  • write documentation

  • add examples in the documentation

DONE:

  • inline everything
  • do we really need the any type? so useless right now :(
    • maybe use them for the very precise type?
  • add custom comparator for merging
  • split the sorting into extra module
  • implement unstable sorting
  • add feature gates for sort and merge
  • add few more tests for kind and so on
  • partial eq can be written top level
  • add limit to dfs
  • do not expose wrapper for Value but use extension
  • add depth parameter to recursive merge

Dependencies

~4.5–6.5MB
~121K SLoC