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
Trying to correct the documentation so that it actually describes how the code behaves. (Attempt two) (simdjson#712)
* Trying to correct the documentation so that it actually describes how the code behaves.
* tweaking the wording.
* Improving.
* Removing confusing sentence.
* Fixing formatting.
* Now with working example, tested.
* Added a smaller piece of code
Copy file name to clipboardExpand all lines: doc/basics.md
+12-5Lines changed: 12 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,9 +59,17 @@ Once you have an element, you can navigate it with idiomatic C++ iterators, oper
59
59
60
60
***Extracting Values:** You can cast a JSON element to a native type: `double(element)` or
61
61
`double x = json_element`. This works for double, uint64_t, int64_t, bool,
62
-
dom::object and dom::array. You can also use is_*typename*()` to test if it is a
63
-
given type, and as_*typename*() to do the cast and return an error code on failure instead of an
64
-
exception.
62
+
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
63
+
given type, 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 use a variant usage of get<*typename*>() with error codes to avoid exceptions: e.g.,
64
+
```c++
65
+
simdjson::error_code error;
66
+
double value; // variable where we store the value to be parsed
0 commit comments