• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# JSON_HAS_FILESYSTEM / JSON_HAS_EXPERIMENTAL_FILESYSTEM
2
3```cpp
4#define JSON_HAS_FILESYSTEM /* value */
5#define JSON_HAS_EXPERIMENTAL_FILESYSTEM /* value */
6```
7
8When compiling with C++17, the library provides conversions from and to
9[`std::filesystem::path`](https://en.cppreference.com/w/cpp/filesystem/path). As compiler support for filesystem is
10limited, the library tries to detect whether
11[`<filesystem>`/`std::filesystem`](https://en.cppreference.com/w/cpp/header/filesystem) (`JSON_HAS_FILESYSTEM`) or
12[`<experimental/filesystem>`/`std::experimental::filesystem`](https://en.cppreference.com/w/cpp/header/experimental/filesystem)
13(`JSON_HAS_EXPERIMENTAL_FILESYSTEM`) should be used. To override the built-in check, define `JSON_HAS_FILESYSTEM` or
14`JSON_HAS_EXPERIMENTAL_FILESYSTEM` to `1`.
15
16## Default definition
17
18The default value is detected based on the preprocessor macros `#!cpp __cpp_lib_filesystem`,
19`#!cpp __cpp_lib_experimental_filesystem`, `#!cpp __has_include(<filesystem>)`, or
20`#!cpp __has_include(<experimental/filesystem>)`.
21
22## Notes
23
24- Note that older compilers or older versions of libstd++ also require the library `stdc++fs` to be linked to for
25  filesystem support.
26- Both macros are undefined outside the library.
27
28## Examples
29
30??? example
31
32    The code below forces the library to use the header `<experimental/filesystem>`.
33
34    ```cpp
35    #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
36    #include <nlohmann/json.hpp>
37
38    ...
39    ```
40
41## Version history
42
43- Added in version 3.10.5.
44