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

已删除 streamdal-transform

snitch组件使用的JSON数据转换库

1个不稳定版本

0.0.7 2023年10月19日

#5#data-manipulation

MIT 许可证

10KB
168 代码行

streamdal-transform

streamdal/wasm库使用的用于对JSON有效负载进行转换的库。

目前仅支持overwritemaskobfuscate

用法

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

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

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

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

重要

  1. overwrite()
    1. 覆盖值将直接使用 - 如果目标应该是字符串,则确保在有效负载中包含引号(例如 "123"
  2. mask() 2. 对数字和字符串有效 3. 对于数字,将替换80%的数字字符为0 4. 对于字符串,将替换80%的字符为*
  3. obfuscate() 2. 仅适用于字符串 3. 将替换100%的字符为sha256散列

直接使用 - 未在生产环境中测试 :)

依赖

~7MB
~88K SLoC