This library is intended to make dynamic transformation of data using serde serializable, deserialize using JSON and a
JSON transformation syntax similar to Javascript JSON syntax.
toml
[dependencies]
proteus = "0.1"
Example usages
```rust
use proteus::{actions, TransformBuilder};
use std::error::Error;
// This example show the basic usage of transformations
fn main() -> Result<(), Box> {
let input = r#"
{
"userid":"111",
"firstname":"Dean",
"lastname":"Karn",
"addresses": [
{ "street":"26 Here Blvd", "postal":"123456", "country":"Canada", "primary":true },
{ "street":"26 Lakeside Cottage Lane.", "postal":"654321", "country":"Canada" }
],
"nested": {
"inner":{
"key":"value"
},
"myarr":[null,"arrvalue",null]
}
}"#;
let trans = TransformBuilder::default()
.addactions(actions!(
("userid", "id"),
(
r#"join(" ", const("Mr."), firstname, lastname)"#,
"full-name"
),
(
r#"join(", ", addresses[0].street, addresses[0].postal, addresses[0].country)"#,
"address"
),
("nested.inner.key", "prevnested"),
("nested.myarr", "myarr"),
(r#"const("arrvalue2")"#, "myarr[]")
)?)
.build()?;
let res = trans.applyfromstr(input)?;
println!("{}", serdejson::tostringpretty(&res)?);
Ok(())
}
```
or when you want to do struct to struct transformations
```rust
use proteus::{actions, TransformBuilder};
use serde::{Deserialize, Serialize};
use std::error::Error;
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Proteus by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.