https://github.com/simd-lite/simd-json-derive
high performance Serialize and Deserialize derives
https://github.com/simd-lite/simd-json-derive
hacktoberfest
Last synced: about 1 year ago
JSON representation
high performance Serialize and Deserialize derives
- Host: GitHub
- URL: https://github.com/simd-lite/simd-json-derive
- Owner: simd-lite
- License: apache-2.0
- Created: 2020-04-15T20:10:31.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-10-24T09:43:14.000Z (over 1 year ago)
- Last Synced: 2024-10-25T06:59:00.192Z (over 1 year ago)
- Topics: hacktoberfest
- Language: Rust
- Homepage:
- Size: 205 KB
- Stars: 32
- Watchers: 7
- Forks: 7
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# simd-json-derive
[](https://crates.io/crates/simd-json-derive)
[](https://docs.rs/simd-json-derive)

Derives for high performance JSON serialisation and deserialisation.
## Usage
```rust
#[derive(Serialize, Deserialize, Debug)]
#[simd_json(deny_unknown_fields, rename_all = "camelCase")]
struct MyStruct {
first_field: String,
#[simd_json(rename = "foo")]
second_field: Option
}
fn main -> Result<(), simd_json::Error> {
let my_struct = MyStruct {
first_field: "i am first".to_string(),
second_field: None
}
println!("Before: {my_struct:?}");
let mut json_string = my_struct.json_string()?;
let deserialized = MyStruct::from_str(json_string.as_mut_str())?;
println!("After: {deserialized:?}");
}
```
## Supported Attributes
Attributes are supported for both `#[simd_json(...)]` and for compatibilty also for `#[serde(...)]` and follow the same naming conventions as serde.
For fields:
* `rename = "new_name"` - renames a field
For structs:
* `rename_all = "camelCase"` - renames all (not otherwise renamed) based on the rule, `camelCase` is currently supported
* `deny_unknown_fields` - Errors if unknown fields are encountered