simdjson.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef SIMDJSON_H
  2. #define SIMDJSON_H
  3. /**
  4. * @mainpage
  5. *
  6. * Check the [README.md](https://github.com/simdjson/simdjson/blob/master/README.md#simdjson--parsing-gigabytes-of-json-per-second).
  7. *
  8. * Sample code. See https://github.com/simdjson/simdjson/blob/master/doc/basics.md for more examples.
  9. #include "simdjson.h"
  10. int main(void) {
  11. // load from `twitter.json` file:
  12. simdjson::dom::parser parser;
  13. simdjson::dom::element tweets = parser.load("twitter.json");
  14. std::cout << tweets["search_metadata"]["count"] << " results." << std::endl;
  15. // Parse and iterate through an array of objects
  16. auto abstract_json = R"( [
  17. { "12345" : {"a":12.34, "b":56.78, "c": 9998877} },
  18. { "12545" : {"a":11.44, "b":12.78, "c": 11111111} }
  19. ] )"_padded;
  20. for (simdjson::dom::object obj : parser.parse(abstract_json)) {
  21. for(const auto key_value : obj) {
  22. cout << "key: " << key_value.key << " : ";
  23. simdjson::dom::object innerobj = key_value.value;
  24. cout << "a: " << double(innerobj["a"]) << ", ";
  25. cout << "b: " << double(innerobj["b"]) << ", ";
  26. cout << "c: " << int64_t(innerobj["c"]) << endl;
  27. }
  28. }
  29. }
  30. */
  31. #include "simdjson/common_defs.h"
  32. // This provides the public API for simdjson.
  33. // DOM and ondemand are amalgamated separately, in simdjson.h
  34. #include "simdjson/simdjson_version.h"
  35. #include "simdjson/base.h"
  36. #include "simdjson/error.h"
  37. #include "simdjson/error-inl.h"
  38. #include "simdjson/implementation.h"
  39. #include "simdjson/minify.h"
  40. #include "simdjson/padded_string.h"
  41. #include "simdjson/padded_string-inl.h"
  42. #include "simdjson/padded_string_view.h"
  43. #include "simdjson/padded_string_view-inl.h"
  44. #include "simdjson/dom.h"
  45. #include "simdjson/ondemand.h"
  46. #endif // SIMDJSON_H