* 📝 overwork macro documentation * 📝 address review comments * 🔧 add style check to Makefile * 🙈 overwork .gitignore * 📌 Pygments 2.12.0 is broken * ✏️ fix links * 🚸 adjust output to cppcheck * 📝 add titles to more admonitions * ✏️ fix typos * 📝 document future behavior change
1.5 KiB
1.5 KiB
JSON_USE_IMPLICIT_CONVERSIONS
#define JSON_USE_IMPLICIT_CONVERSIONS /* value */
When defined to 0, implicit conversions are switched off. By default, implicit conversions are switched on. The
value directly affects operator ValueType.
Implicit conversions can also be controlled with the CMake option JSON_ImplicitConversions (ON by default) which
sets JSON_USE_IMPLICIT_CONVERSIONS accordingly.
Default definition
By default, implicit conversions are enabled.
#define JSON_USE_IMPLICIT_CONVERSIONS 1
Notes
!!! info "Future behavior change"
Implicit conversions will be switched off by default in the next major release of the library.
You can prepare existing code by already defining `JSON_USE_IMPLICIT_CONVERSIONS` to `0` and replace any implicit
conversions with calls to [`get`](../basic_json/get.md).
Examples
??? example
This is an example for an implicit conversion:
```cpp
json j = "Hello, world!";
std::string s = j;
```
When `JSON_USE_IMPLICIT_CONVERSIONS` is defined to `0`, the code above does no longer compile. Instead, it must be
written like this:
```cpp
json j = "Hello, world!";
auto s = j.get<std::string>();
```
See also
- operator ValueType - get a value (implicit)
- get - get a value (explicit)
Version history
- Added in version 3.9.0.