Skip to content

Fix missing exports from json.cppm#5137

Open
mikomikotaishi wants to merge 7 commits intonlohmann:developfrom
mikomikotaishi:patch-1
Open

Fix missing exports from json.cppm#5137
mikomikotaishi wants to merge 7 commits intonlohmann:developfrom
mikomikotaishi:patch-1

Conversation

@mikomikotaishi
Copy link
Copy Markdown
Contributor

@mikomikotaishi mikomikotaishi commented Apr 15, 2026

[Describe your pull request here. Please read the text below the line and make sure you follow the checklist.]

This pull request restores some missing symbols that were present in the <nlohmann/json.hpp> header, but weren't exported in json.cppm. These include specialisations in namespace std (such as hash<> and less<>), as well as nlohmann::literals::json_literals::*. This is necessary as without this those specialisations and symbols are inaccessible from the module.

  • The changes are described in detail, both the what and why.
  • If applicable, an existing issue is referenced.
  • The Code coverage remained at 100%. A test case for every new line of code.
  • If applicable, the documentation is updated.
  • The source code is amalgamated by running make amalgamate.

Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com>
@github-actions github-actions Bot added the M label Apr 15, 2026
Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com>
Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com>
Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com>
Comment thread docs/mkdocs/docs/features/modules.md Outdated
- `nlohmann::ordered_map`
- `nlohmann::to_string`
- `nlohmann::detail::json_sax_dom_callback_parser`
- `nlohmann::detail::unknown_size`
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Libraries should not rely on any symbols from the details namespace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was in the previous version of the module which is why I kept it in, but if you'd prefer I'll remove it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefer that I just omit the mention of nlohmann::detail::* symbols from the documentation, but leave it exported in the module? I wasn't sure why someone (#4952) amended it to export those symbols "for advanced usage", but I'll leave it to your call whether to keep it exported in the module or not, and if to keep it whether to keep it mentioned in the webpage.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please remove them.

Copy link
Copy Markdown
Contributor Author

@mikomikotaishi mikomikotaishi Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, removed nlohmann::detail::* from both the module and the docs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I didn't realise that #3970 mentioned that exporting these internals was literally necessary on MSVC. I think the most reasonable approach is to export it but leave mention of it omitted from documentation, as it's purely an implementation detail.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Maybe mention the ticket in the code so we know this in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment with the ticket number

Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com>
Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com>
Signed-off-by: Miko <110693261+mikomikotaishi@users.noreply.github.com>
@mikomikotaishi
Copy link
Copy Markdown
Contributor Author

@nlohmann Anything else left to address in this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants