Crates.io | streamdal-wasm-transform |
lib.rs | streamdal-wasm-transform |
version | 0.1.6 |
source | src |
created_at | 2023-10-21 01:15:58.246791 |
updated_at | 2024-01-05 15:08:14.350137 |
description | JSON data transformation lib used by snitch components |
homepage | |
repository | https://github.com/streamdal/wasm-transform |
max_upload_size | |
id | 1009703 |
size | 50,120 |
Library used by streamdal/wasm to perform transformations on JSON payloads.
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,
)
}
overwrite()
"123"
)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 *
obfuscate()
2. Works ONLY on strings
3. Will replace 100% of the characters with a sha256 hashdelete_path()
2. Does not work on array elements yettruncate()
2. Works on strings
3. For strings, it will truncate the string to the specified length