Skip to content

Commit

Permalink
Merge pull request #23 from SunDoge/c_api
Browse files Browse the repository at this point in the history
C api
  • Loading branch information
SunDoge committed Aug 24, 2023
2 parents 5faa5b2 + 1347fc4 commit 0e5a90f
Show file tree
Hide file tree
Showing 43 changed files with 1,432 additions and 64,404 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true

# Cache
- name: Cache
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Cargo.lock

.vscode/
.idea/

.cache/
build/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "simdjson-sys/simdjson"]
path = simdjson-sys/simdjson
url = https://github.com/simdjson/simdjson.git
20 changes: 7 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
[package]
name = "simdjson-rust"
version = "0.2.0-alpha"
version = "0.3.0"
authors = ["SunDoge <384813529@qq.com>"]
edition = "2018"
links = "simdjson-rust"
edition = "2021"
license = "Apache-2.0"
exclude = [".github/", "examples/"]

# [dependencies]
# simdjson-sys = {path="simdjson-sys"}

# [workspace]
# members = ["simdjson-sys"]
[workspace]
members = ["simdjson-sys"]


[dependencies]
cxx = "1.0.74"
thiserror = "1.0"
# anyhow = "1.0"
simdjson-sys = { path = "simdjson-sys" }

# serde compatibilty
serde = { version = "1", features = ["derive"], optional = true }
serde_json = { version = "1", optional = true }

[build-dependencies]
cxx-build = "1.0.74"


[features]
default = ["serde_impl"]
default = []

# serde compatibility
serde_impl = ["serde", "serde_json"]
33 changes: 11 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![CI](https://github.com/SunDoge/simdjson-rust/actions/workflows/CI.yml/badge.svg)](https://github.com/SunDoge/simdjson-rust/actions/workflows/CI.yml)

This crate currently uses `simdjson 2.2.2`. You can have a try and give feedback.
This crate currently uses `simdjson 3.2.3`. You can have a try and give feedback.

## Usage

Expand All @@ -16,27 +16,16 @@ simdjson-rust = {git = "https://github.com/SunDoge/simdjson-rust"}
Then, get started.

```rust
use simdjson_rust::dom;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut parser = dom::Parser::default();
let tweets = parser.load("json-examples/twitter.json")?;
println!(
"{} results.",
tweets
.at_key("search_metadata")?
.at_key("count")?
.get_u64()?
);
use simdjson_rust::{error::Result, ondemand::parser::Parser, padded_string::make_padded_string};

fn main() -> Result<()> {
let mut parser = Parser::default();
let ps = make_padded_string("[0,1,2,3]");
let mut doc = parser.iterate(&ps)?;
let mut array = doc.get_array()?;
for (index, value) in array.iter()?.enumerate() {
assert_eq!(index as u64, value?.get_uint64()?);
}
Ok(())
}
```

## Roadmap

- [x] ParsedJson
- [x] ParsedJsonIterator
- [x] printjson (impl Display)
- [x] ci
- [ ] tests
- [ ] benchmark
21 changes: 0 additions & 21 deletions build.rs

This file was deleted.

0 comments on commit 0e5a90f

Please sign in to comment.