Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #5

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ citm_catalog/serde_json::to_string
```

### Get from JSON
` cargo bench --bench get_from -- --quiet`
`cargo bench --bench get_from -- --quiet`

```
twitter/sonic-rs::get_from_str
Expand All @@ -166,7 +166,7 @@ twitter/gjson::get time: [344.41 µs 351.36 µs 362.03 µs]

Directly use the `Deserialize` or `Serialize` trait, recommended use `sonic_rs::{Deserialize, Serialize}`.

```
```rs
use sonic_rs::{Deserialize, Serialize};
// or use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -197,7 +197,7 @@ fn main() {

Get a specific field from a JSON with the `pointer` path. The return is a `LazyValue`, which is a wrapper of a raw JSON slice. Note that the JSON must be valid and well-formed, otherwise it may return unexpected result.

```
```rs
use sonic_rs::{get_from_str, pointer, JsonValue, PointerNode};

fn main() {
Expand All @@ -223,7 +223,7 @@ fn main() {

Parse a JSON as a document, and the document is mutable.

```
```rs
use sonic_rs::value::{dom_from_slice, Value};
use sonic_rs::PointerNode;
use sonic_rs::{pointer, JsonValue};
Expand Down Expand Up @@ -263,14 +263,13 @@ fn main() {
obj.insert("inserted", value);
assert!(obj.contains_key("inserted"));
}

```

### JSON Iterator

Parse a object or array JSON into a iterator. The `item` of iterator is the LazyValue, which is wrapper of a raw JSON slice.
Parse a object or array JSON into a iterator. The `item` of iterator is the `LazyValue`, which is wrapper of a raw JSON slice.

```
```rs
use bytes::Bytes;
use sonic_rs::{to_array_iter, JsonValue};

Expand All @@ -294,4 +293,4 @@ fn main() {
```

## Contributing
Please read `CONTRIBUTING.md` for information on contributing to sonic-rs.
Please read `CONTRIBUTING.md` for information on contributing to sonic-rs.