Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions docs/mkdocs/docs/features/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,21 @@ 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, but rather only the following symbols:
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_serializer`
- `nlohmann::basic_json`
- `nlohmann::json`
- `nlohmann::json_pointer`
- `nlohmann::ordered_map`
- `nlohmann::ordered_json`
- `nlohmann::ordered_map`
- `nlohmann::to_string`
- `nlohmann::literals::json_literals::operator""_json`
- `nlohmann::literals::json_literals::operator""_json_pointer`
The following specialisations of `std` symbols are also exported:
- `std::hash`
- `std::less`
- `std::swap`
56 changes: 37 additions & 19 deletions src/modules/json.cppm
Original file line number Diff line number Diff line change
@@ -1,32 +1,50 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.12.0
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT

module;

#include <nlohmann/json.hpp>

export module nlohmann.json;

export namespace nlohmann {
using ::nlohmann::adl_serializer;
using ::nlohmann::basic_json;
using ::nlohmann::json;
using ::nlohmann::json_pointer;
using ::nlohmann::ordered_json;
using ::nlohmann::ordered_map;
} // namespace nlohmann

export
NLOHMANN_JSON_NAMESPACE_BEGIN

using NLOHMANN_JSON_NAMESPACE::adl_serializer;
using NLOHMANN_JSON_NAMESPACE::basic_json;
using NLOHMANN_JSON_NAMESPACE::json;
using NLOHMANN_JSON_NAMESPACE::json_pointer;
using NLOHMANN_JSON_NAMESPACE::ordered_json;
using NLOHMANN_JSON_NAMESPACE::ordered_map;
using NLOHMANN_JSON_NAMESPACE::to_string;

inline namespace literals
{
inline namespace json_literals
{
using NLOHMANN_JSON_NAMESPACE::literals::json_literals::operator""_json;
using NLOHMANN_JSON_NAMESPACE::literals::json_literals::operator""_json_pointer;
} // namespace json_literals
} // namespace literals

// Note: the following nlohmann::detail symbols must be exported due to
// an MSVC bug failing to compile without these symbols visible (ticket #3970)
namespace detail
{
export using NLOHMANN_JSON_NAMESPACE::detail::json_sax_dom_callback_parser;
export using NLOHMANN_JSON_NAMESPACE::detail::unknown_size;
using NLOHMANN_JSON_NAMESPACE::detail::json_sax_dom_callback_parser;
using NLOHMANN_JSON_NAMESPACE::detail::unknown_size;
} // namespace detail

export using NLOHMANN_JSON_NAMESPACE::adl_serializer;
export using NLOHMANN_JSON_NAMESPACE::basic_json;
export using NLOHMANN_JSON_NAMESPACE::json;
export using NLOHMANN_JSON_NAMESPACE::json_pointer;
export using NLOHMANN_JSON_NAMESPACE::ordered_json;
export using NLOHMANN_JSON_NAMESPACE::ordered_map;
export using NLOHMANN_JSON_NAMESPACE::to_string;

NLOHMANN_JSON_NAMESPACE_END

export namespace std
{
using std::hash;
using std::less;
using std::swap;
} // namespace std
Loading