#json #transform #replace #snitch #obfuscate #data-manipulation #data-transformation

streamdal-wasm-transform

JSON data transformation lib used by snitch components

12 releases

0.1.6 Jan 5, 2024
0.1.5 Jan 5, 2024
0.0.11 Oct 21, 2023
0.0.2 Jan 3, 2024
0.0.1 Dec 19, 2023

#4 in #data-manipulation

Download history 23/week @ 2023-12-29 17/week @ 2024-01-05 7/week @ 2024-02-23 7/week @ 2024-03-01 46/week @ 2024-03-22 99/week @ 2024-03-29

145 downloads per month

MIT license

29KB
624 lines

Release Test

streamdal-transform

Library used by streamdal/wasm to perform transformations on JSON payloads.

Usage

fn main() {
    let sample_json = r#"{"hello": "world"}"#;

    let req = streamdal_wasm_transform::transform::Request {
        data: sample_json.into(),
        path: "hello".to_string(),
        value: r#""baz""#.to_string(),
    };

    let updated_json = streamdal_wasm_transform::transform::overwrite(&req).unwrap();

    println!(
        "Input JSON: {} || Result JSON: {}",
        sample_json, updated_json,
    )
}

IMPORTANT

  1. overwrite()
    1. Overwrite value will be used as-is - if target is intended to be a string, then make sure to include quotes in the payload ( Ie. "123")
  2. mask() 2. Works for numbers and strings 3. For numbers, it will replace 80% of the number characters with 0 4. For strings, it will replace 80% of the characters with *
  3. obfuscate() 2. Works ONLY on strings 3. Will replace 100% of the characters with a sha256 hash
  4. delete_path() 2. Does not work on array elements yet
  5. truncate() 2. Works on strings 3. For strings, it will truncate the string to the specified length

Dependencies

~7.5MB
~104K SLoC