* Fix missing exports from `json.cppm` Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com> * Update documentation to describe what symbols are exported Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com> * Add mention of `std` symbols Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com> * Add `json_literals` inline namespace to `using` statement Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com> * Remove internals (`nlohmann::detail::*`) from module Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com> * Omit internals (`nlohmann::detail::*`) from modules documentation Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com> * Restore `nlohmann::detail` symbols with mention of the MSVC bug Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com> --------- Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com>
1.6 KiB
Modules
This library has experimental support for C++ modules, introduced in C++20. The library can be imported by writing import nlohmann.json; instead of #include <nlohmann/json.hpp>.
Please be aware that the module is experimental and a full test is outstanding, and the exported symbols are subject to change.
Requirements
The nlohmann.json module requires that the build system is configured to build and resolve modules when imported. Obviously, as modules were introduced in C++20, this feature can only be used in C++20 and subsequent versions.
To enable building the nlohmann.json module (which is not done by default), the macro NLOHMANN_JSON_BUILD_MODULES must be passed to the build system.
Example
When using modules rather than headers, the previous example for creating a json object through a JSON file, would instead be:
import std;
import nlohmann.json;
using json = nlohmann::json;
// ...
std::ifstream f("example.json");
json data = json::parse(f);
Modules do not export macros
It should be noted that as modules do not export macros, the nlohmann.json module will not export any macros.
Exported symbols
Only the following symbols are exported from nlohmann.json:
nlohmann::adl_serializernlohmann::basic_jsonnlohmann::jsonnlohmann::json_pointernlohmann::ordered_jsonnlohmann::ordered_mapnlohmann::to_stringnlohmann::literals::json_literals::operator""_jsonnlohmann::literals::json_literals::operator""_json_pointer
The following specialisations of std symbols are also exported:
std::hashstd::lessstd::swap