1# JSON_USE_IMPLICIT_CONVERSIONS 2 3```cpp 4#define JSON_USE_IMPLICIT_CONVERSIONS /* value */ 5``` 6 7When defined to `0`, implicit conversions are switched off. By default, implicit conversions are switched on. The 8value directly affects [`operator ValueType`](../basic_json/operator_ValueType.md). 9 10## Default definition 11 12By default, implicit conversions are enabled. 13 14```cpp 15#define JSON_USE_IMPLICIT_CONVERSIONS 1 16``` 17 18## Notes 19 20!!! info "Future behavior change" 21 22 Implicit conversions will be switched off by default in the next major release of the library. 23 24 You can prepare existing code by already defining `JSON_USE_IMPLICIT_CONVERSIONS` to `0` and replace any implicit 25 conversions with calls to [`get`](../basic_json/get.md). 26 27!!! hint "CMake option" 28 29 Implicit conversions can also be controlled with the CMake option 30 [`JSON_ImplicitConversions`](../../integration/cmake.md#json_legacydiscardedvaluecomparison) 31 (`ON` by default) which defines `JSON_USE_IMPLICIT_CONVERSIONS` accordingly. 32 33## Examples 34 35??? example 36 37 This is an example for an implicit conversion: 38 39 ```cpp 40 json j = "Hello, world!"; 41 std::string s = j; 42 ``` 43 44 When `JSON_USE_IMPLICIT_CONVERSIONS` is defined to `0`, the code above does no longer compile. Instead, it must be 45 written like this: 46 47 ```cpp 48 json j = "Hello, world!"; 49 auto s = j.template get<std::string>(); 50 ``` 51 52## See also 53 54- [**operator ValueType**](../basic_json/operator_ValueType.md) - get a value (implicit) 55- [**get**](../basic_json/get.md) - get a value (explicit) 56 57## Version history 58 59- Added in version 3.9.0. 60