Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json constructor does not support std::optional #2214

Closed
gzliudan opened this issue Jun 24, 2020 · 2 comments
Closed

json constructor does not support std::optional #2214

gzliudan opened this issue Jun 24, 2020 · 2 comments
Labels
kind: bug solution: duplicate the issue is a duplicate; refer to the linked issue instead

Comments

@gzliudan
Copy link

gzliudan commented Jun 24, 2020

I'm using clang 9.0 which support C++17, but below codes can't pass compile when I use nlohmann::json:

std::optional<int> value;
auto json = nlohmann::json{{"opt", value}};

instead, I have to use below codes:
if (value) {
    json = nlohmann::json{{"opt", *value}};
} else {
    json = nlohmann::json{{"opt", nullptr}};
}
@dota17
Copy link
Contributor

dota17 commented Jun 24, 2020

Please See #1749 .
There is a PR #2117 , but it didn't merge into develop because there are some problems.

@nlohmann
Copy link
Owner

Duplicate of #1749.

@nlohmann nlohmann added the solution: duplicate the issue is a duplicate; refer to the linked issue instead label Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug solution: duplicate the issue is a duplicate; refer to the linked issue instead
Projects
None yet
Development

No branches or pull requests

3 participants