Skip to content

Commit c8a70a0

Browse files
author
Daniel Lemire
committed
Tweaking the documentation.
1 parent b84a3a0 commit c8a70a0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

doc/basics.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ Using the Parsed JSON
7575

7676
Once you have an element, you can navigate it with idiomatic C++ iterators, operators and casts.
7777

78-
* **Extracting Values:** You can cast a JSON element to a native type: `double(element)` or
78+
* **Extracting Values (with exceptions):** You can cast a JSON element to a native type: `double(element)` or
7979
`double x = json_element`. This works for double, uint64_t, int64_t, bool,
80-
dom::object and dom::array. An exception is thrown if the cast is not possible. You can also use is<*typename*>() to test if it is a given type, or use the equivalent without templates (`is_uint64()`, `is_uint64()`, `is_number()`, `is_double()`, , `is_bool()`, `is_integer()`, `is_string()`, `is_array()`, `is_object()`) or use the `type()` method: e.g., `element.type() == dom::element_type::DOUBLE`. Instead of casting, you can use get<*typename*>() to get the value: casts and get<*typename*>() can be used interchangeably. You can also use equivalent functions without templates: e.g., `get_string()`, `get_int64()`, `get_uint64()`, `get_double()` and `get_bool()`. You can use a variant usage of get<*typename*>() with error codes to avoid exceptions: e.g.,
80+
dom::object and dom::array. An exception is thrown if the cast is not possible.
81+
* **Extracting Values (without expceptions):** You can use a variant usage of `get()` with error codes to avoid exceptions. You first declare the variable of the appropriate type (`double`, `uint64_t`, `int64_t`, `bool`,
82+
`dom::object` and `dom::array`) and pass it by reference to `get()` which gives you back an error code: e.g.,
8183
```c++
8284
simdjson::error_code error;
8385
simdjson::padded_string numberstring = "1.2"_padded; // our JSON input ("1.2")

0 commit comments

Comments
 (0)