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

I have a query regarding nlohmann::basic_json::basic_json #1174

Closed
sonulohani opened this issue Jul 26, 2018 · 8 comments
Closed

I have a query regarding nlohmann::basic_json::basic_json #1174

sonulohani opened this issue Jul 26, 2018 · 8 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@sonulohani
Copy link
Contributor

Hi @nlohmann ,

While i was understanding the json code, I've got involved into a question. In this link:- https://nlohmann.github.io/json/classnlohmann_1_1basic__json_ab5dfd9a2b2663b219641cb7fe59b6da2.html#ab5dfd9a2b2663b219641cb7fe59b6da2 in the ctor "basic_json" I want to pass type_deduction as false. How can i do that.

@nlohmann
Copy link
Owner

You could try:

auto j = basic_json({{"foo", "bar"}}, false);

@nlohmann nlohmann added kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation labels Jul 26, 2018
@sonulohani
Copy link
Contributor Author

@nlohmann Thank you.

@sonulohani
Copy link
Contributor Author

sonulohani commented Jul 26, 2018

Hi @nlohmann ,

I am doing like this:-

using nlohmann::json;
json j_array = json({13, 29, 3, {{"one", 1}, {"two", 2}}, true, false, {1, 2, 3}, "foo", "baz"}, false);

But the value of type_deduction is still true.

@nlohmann
Copy link
Owner

I guess you then also need to pass a value for manual_type. These are actually internal parameters.

@sonulohani
Copy link
Contributor Author

Hi @nlohmann,

I got it now. Thanks for the answer. Yeah those were internal parameters.

@nlohmann
Copy link
Owner

If you just want to enforce that an array is created, it is better to make this explicit by using this function: https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aa80485befaffcadaa39965494e0b4d2e.html#aa80485befaffcadaa39965494e0b4d2e (it uses the other constructor internally)

@nlohmann
Copy link
Owner

@sonulohani Can I close this issue?

@sonulohani
Copy link
Contributor Author

@nlohmann Yeah sure. Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants