You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-17Lines changed: 22 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,19 @@
1
-
# lua-simdjson
2
-
A basic lua binding to [simdjson](https://simdjson.org). The simdjson library is an incredibly fast JSON parser that uses SIMD instructions and fancy algorithms to parse JSON very quickly. It's been tested with LuaJIT 2.0/2.1 and Lua 5.1, 5.2, and 5.3 on linux
A basic lua binding to [simdjson](https://simdjson.org). The simdjson library is an incredibly fast JSON parser that uses SIMD instructions and fancy algorithms to parse JSON very quickly. It's been tested with LuaJIT 2.0/2.1 and Lua 5.1, 5.2, 5.3, and 5.4 on linux/osx. It has a general parsing mode and a lazy mode that uses a JSON pointer.
3
5
4
6
Current simdjson version: 0.3.1
5
7
6
8
## Requirements
7
9
* lua-simdjson only works on 64bit systems.
8
-
* a modern lua build environment with g++ and support for C++11
10
+
* a lua build environment with support for C++11
11
+
* g++ version 7+ and clang++ version 6+ or newer should work!
9
12
10
13
## Parsing
11
14
There are two main ways to parse JSON in lua-simdjson:
12
15
1. With `parse`: this parses JSON and returns a lua table with the parsed values
13
-
2. With `open`: this reads in the JSON and keeps it in simdjson's internal format. It can then be accessed using a JSON pointer (examples below)
16
+
2. With `open`: this reads in the JSON and keeps it in simdjson's internal format. The values can then be accessed using a JSON pointer (examples below)
14
17
15
18
Both of these methods also have support to read files on disc with `parseFile` and `openFile` respectively. If handling JSON from disk, these methods should be used and are incredibly fast.
16
19
@@ -40,7 +43,7 @@ local response = simdjson.parse([[
print(fileResponse:at("statuses/0/id")) --using a JSON pointer
76
79
77
80
```
78
81
The `open` and `parse` codeblocks should print out the same values. It's worth noting that the JSON pointer indexes from 0.
79
82
80
83
This lazy style of using the simdjson data structure could also be used with array access in the future, and would result in ultra-fast JSON parsing.
81
84
85
+
## Error Handling
86
+
lua-simdjson will error out with any errors from simdjson encountered while parsing. They are very good at helping identify what has gone wrong during parsing.
87
+
82
88
## Benchmarks
83
89
TODO: add some benchmarks
84
90
85
-
## Caveats
86
-
* there is no encoding/dumping a lua table to JSON (yet!)
87
-
* it only works on 64 bit systems (possibly only Linux, more testing is needed)
91
+
## Caveats & Alternatives
92
+
* there is no encoding/dumping a lua table to JSON (yet! Most other lua JSON libraries can handle this)
93
+
* it only works on 64 bit systems (untested on Windows...)
88
94
* it builds a large binary. On a modern linux system, it ended up being \~200k (lua-cjson comes in at 42k)
89
-
* since it's an external module, it's not quite as easy to just grab the file and go.
90
-
* it needs a compiler that supports at least C++11
95
+
* since it's an external module, it's not quite as easy to just grab the file and go (dkjson has you covered here!)
91
96
92
-
## Error Handling
93
-
lua-simdjson will error out with any errors from simdjson encountered while parsing. They are fairly informative as to what has gone wrong during parsing.
97
+
## Philosophy
98
+
I plan to keep it fairly inline with what the original simdjson library is capable of doing, which really means not adding too many additional options. The big _thing_ that's missing so far is encoding a lua table to JSON. I may add in an encoder at some point (likely modified from an existing lua library). There are some rumours that simdjson _may_ support creating JSON structure in the future. If that happens, I would likely switch to it.
94
99
95
100
## Licenses
96
101
* The jsonexamples, src/simdjson.cpp, src/simdjson.h are unmodified from the released version simdjson under the Apache License 2.0.
97
-
* All other files/folders are apart of lua-cjson also under the Apache License 2.0.
102
+
* All other files/folders are apart of lua-simdjson also under the Apache License 2.0.
0 commit comments