[][src]Crate simd_json

simdjson-rs is a rust port of the simejson c++ library. It follows most of the design closely with a few exceptions to make it better fit into the rust ecosystem.

Note: by default rustc will compile for compatibility, not performance, to take advantage of the simd part of simd json. You have to use a native cpu target on a avx2 capable host system. An example how to do this can be found in the .cargo directory on github.

Goals

the goal of the rust port of simdjson is not to create a one to one copy, but to integrate the principles of the c++ library into a rust library that plays well with the rust ecosystem. As such we provide both compatibility with serde as well as parsing to a dom to manipulate data.

Performance

As a rule of thumb this library tries to get as close as posible to the performance of the c++ implementation, but some of the design decisions - such as parsing to a dom or a tape, weigh ergonomics over performance. In other places Rust makes it harder to achive the same level of performance.

Safety

this library uses unsafe all over the place, and while it leverages quite a few test cases along with property based testing, please use this library with caution.

Usage

simdjson-rs offers two main entry points for usage:

Values API

The values API is a set of optimized DOM objects that allow parsed json to JSON data that has no known variable structure. simdjson-rs has two versions of this:

Borrowed Values

use simd_json;
let mut d = br#"{"some": ["key", "value", 2]}"#.to_vec();
let v: simd_json::BorrowedValue = simd_json::to_borrowed_value(&mut d).unwrap();

Owned Values

use simd_json;
let mut d = br#"{"some": ["key", "value", 2]}"#.to_vec();
let v: simd_json::OwnedValue = simd_json::to_owned_value(&mut d).unwrap();

Serde Comaptible API

use simd_json;
use serde_json::Value;

let mut d = br#"{"some": ["key", "value", 2]}"#.to_vec();
let v: Value = simd_json::serde::from_slice(&mut d).unwrap();

Re-exports

pub use crate::value::*;

Modules

serde
value

Macros

json

Taken from: https://github.com/serde-rs/json/blob/5b5f95831d9e0d769367b30b76a686339bffd209/src/macros.rs Construct a simdjson::Value from a JSON literal.

likely
static_cast_i8
static_cast_i32
static_cast_i64
static_cast_u32
static_cast_u64
stry
unlikely

Structs

Deserializer
Error

Enums

ErrorType

Type Definitions

Result