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: doc/basics.md
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -98,10 +98,11 @@ Using the Parsed JSON
98
98
99
99
Once you have an element, you can navigate it with idiomatic C++ iterators, operators and casts.
100
100
101
-
***Extracting Values:** You can cast a JSON element to a native type: `double(element)` or
101
+
***Extracting Values (with exceptions):** You can cast a JSON element to a native type: `double(element)` or
102
102
`double x = json_element`. This works for double, uint64_t, int64_t, bool,
103
-
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
104
-
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.,
103
+
dom::object and dom::array. An exception is thrown if the cast is not possible.
104
+
***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`,
105
+
`dom::object` and `dom::array`) and pass it by reference to `get()` which gives you back an error code: e.g.,
0 commit comments