#json-object #flatten #ietf-rfc #pointers #array #defined #addressing

jsonpointer_flatten

Library to flatten a JSON object or array using JSON Pointer addressing

4 releases

0.1.3 Aug 7, 2021
0.1.2 Aug 7, 2021
0.1.1 Aug 7, 2021
0.1.0 Aug 6, 2021

#2075 in Encoding

Custom license

9KB
164 lines

jsonpointer_flatten

crates.io docs.rs

Rust library to flatten a JSON object using JSON Pointer field addressing as defined in IETF RFC 6901.

Usage

let value = json!(
    {
        "name": "John Smith",
        "age": 24,
        "address": {
            "country": "US",
            "zip": "00000"
        },
        "phones": [ "123", "456" ]
    }
);

let actual = jsonpointer_flatten::from_json(&value);

Outputs

{
  "": {},
  "/address": {},
  "/address/country": "US",
  "/address/zip": "00000",
  "/age": 24,
  "/name": "John Smith",
  "/phones": [],
  "/phones/0": "123",
  "/phones/1": "456"
}

lib.rs:

Rust library to flatten a JSON object using JSON Pointer field addressing as defined in IETF RFC 6901.

Dependencies

~0.7–1.6MB
~35K SLoC