diff --git a/README.md b/README.md
index 163e1a624..8a6554db2 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,45 @@
-# simdjson : Parsing gigabytes of JSON per second
+# simdjson : Parsing gigabytes of JSON per second
+
+
+JSON is everywhere on the Internet. Servers spend a *lot* of time parsing it. We need a fresh approach. simdjson uses commonly available SIMD instructions and microparallel algorithms to parse JSON 2.5x faster than anything else out there.
+
+* **Ludicrous Speed:** Over 2.5x faster than other production-grade JSON parsers.
+* **Delightfully Easy:** First-class, easy to use API.
+* **Complete Validation:** Full JSON and UTF-8 validation, with no compromises.
+* **Rock-Solid Reliability:** From memory allocation to error handling, simdjson's design avoids surprises.
+
+This library is part of the [Awesome Modern C++](https://awesomecpp.com) list.
+
[](https://cloud.drone.io/simdjson/simdjson)
[](https://circleci.com/gh/simdjson/simdjson)
[](https://ci.appveyor.com/project/lemire/simdjson-jmmti/branch/master)
[![][license img]][license]
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:simdjson)
+## Quick Start
-## A C++ library to see how fast we can parse JSON with complete validation.
+simdjson is easily consumable with a single .h and .cpp file.
-JSON documents are everywhere on the Internet. Servers spend a lot of time parsing these documents. We want to accelerate the parsing of JSON per se using commonly available SIMD instructions as much as possible while doing full validation (including character encoding). This library is part of the [Awesome Modern C++](https://awesomecpp.com) list.
+0. Prerequisites: `g++` or `clang++`.
+1. Pull [simdjson.h](singleheader/simdjson.h) and [simdjson.cpp](singleheader/simdjson.h) into a directory, along with the sample file [twitter.json](jsonexamples/twitter.json).
+ ```
+ wget https://raw.githubusercontent.com/simdjson/simdjson/master/singleheader/simdjson.h https://raw.githubusercontent.com/simdjson/simdjson/master/singleheader/simdjson.cpp https://raw.githubusercontent.com/simdjson/simdjson/master/jsonexamples/twitter.json
+ ```
+2. Create `parser.cpp`:
-
+ ```c++
+ #include "simdjson.h"
+ int main(void) {
+ simdjson::document::parser parser;
+ simdjson::document& tweets = parser.load("twitter.json");
+ std::cout << tweets["search_metadata"]["count"] << " results." << std::endl;
+ }
+ ```
+3. `g++ -o parser parser.cpp` (or clang++)
+4. `./parser`
+ ```
+ 100 results.
+ ```
## Real-world usage
diff --git a/singleheader/amalgamation_demo.cpp b/singleheader/amalgamation_demo.cpp
index 759dc41c3..4979e0f79 100755
--- a/singleheader/amalgamation_demo.cpp
+++ b/singleheader/amalgamation_demo.cpp
@@ -1,4 +1,4 @@
-/* auto-generated on Thu Mar 5 10:30:07 PST 2020. Do not edit! */
+/* auto-generated on Fri Mar 20 11:47:31 PDT 2020. Do not edit! */
#include
#include "simdjson.h"
@@ -8,37 +8,31 @@ int main(int argc, char *argv[]) {
std::cerr << "Please specify at least one file name. " << std::endl;
}
const char * filename = argv[1];
- simdjson::padded_string p = simdjson::get_corpus(filename);
- auto [doc, error] = simdjson::document::parse(p); // do the parsing
+ simdjson::document::parser parser;
+ auto [doc, error] = parser.load(filename); // do the parsing
if (error) {
- std::cout << "document::parse failed" << std::endl;
+ std::cout << "parse failed" << std::endl;
std::cout << "error code: " << error << std::endl;
std::cout << error << std::endl;
} else {
- std::cout << "document::parse valid" << std::endl;
+ std::cout << "parse valid" << std::endl;
}
if(argc == 2) {
return EXIT_SUCCESS;
}
- //JsonStream
+ // parse_many
const char * filename2 = argv[2];
- simdjson::padded_string p2 = simdjson::get_corpus(filename2);
- simdjson::document::parser parser;
- simdjson::JsonStream js{p2};
- int parse_res = simdjson::SUCCESS_AND_HAS_MORE;
-
- while (parse_res == simdjson::SUCCESS_AND_HAS_MORE) {
- parse_res = js.json_parse(parser);
+ for (auto result : parser.load_many(filename2)) {
+ error = result.error();
}
-
- if( ! parser.is_valid()) {
- std::cout << "JsonStream not valid" << std::endl;
+ if (error) {
+ std::cout << "parse_many failed" << std::endl;
+ std::cout << "error code: " << error << std::endl;
+ std::cout << error << std::endl;
} else {
- std::cout << "JsonStream valid" << std::endl;
+ std::cout << "parse_many valid" << std::endl;
}
-
-
return EXIT_SUCCESS;
}
diff --git a/singleheader/simdjson.cpp b/singleheader/simdjson.cpp
index ba25e97a6..f096537e4 100644
--- a/singleheader/simdjson.cpp
+++ b/singleheader/simdjson.cpp
@@ -1,4 +1,4 @@
-/* auto-generated on Thu Mar 5 10:30:07 PST 2020. Do not edit! */
+/* auto-generated on Fri Mar 20 11:47:31 PDT 2020. Do not edit! */
#include "simdjson.h"
/* used for http://dmalloc.com/ Dmalloc - Debug Malloc Library */
@@ -7,67 +7,7 @@
#endif
/* begin file src/simdjson.cpp */
-/* begin file src/error.cpp */
-#include