-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[Question] copy assign json-container to vector #635
Comments
I'm on holiday, but I am confident someone finds an answer. |
I see, the implicit conversion (without calling You can solve this easily however: auto v = j.get<std::vector<double>>(); |
Thanks, that solves my problem with the conversion. Is it okay for you, if I post this as an answer at stackoverflow in case someone else might have the same problem? I assumed searching for a lower bound with the code above isn't possible. Could you also explain whether this is correct? |
Of course! Well, since your array is sorted, this should work as expected. |
Thanks! It does not work as expected. If I try to compile it, I get the following error:
|
I see, this is a known bug, that is fixed on develop. Could you try the proposed workaround in #486 ? EDIT: this might be an unrelated bug, it's weird to have |
Just using the workaround
before the main-method should do it, right? I also tried the json.hpp from the commit which fixes the bug. Both didn't help. You might be right about this being an unrelated bug. |
Hmm, I'll try to find some time to fix it. What is your test file? The code in your first post? |
Yes. |
After bissecting for a while, I found the commit that fixes your bug, this is 90273e9. You could hijack the |
Converting to a vector is not a problem and should be more performant when using lower bound multiple times. I could just use the json.hpp from the develop-branch, right? |
Hmm, I would not recommand using develop frankly... there are some breaking changes. Converting to |
Is there anything left to do here? |
As far as I'm concerned, no. |
OK. Thanks for checking back! |
Hi,
upon the recommendation of Niels Lohmann via e-mail, I want to refer to a question I asked on stackoverflow.
Let me share why I am asking that question: I am trying to search for a "lower bound" in a json-object. I assume this can't work since comparing with a double (or integer) isn't possible. That is why I need the conversion (via copy-assign) to a vector. If the question I referred to is not needed because you can solve the error with the lower bound (see code below), it would be great. But I think using vectors would still be relevant since it would be more efficient, if you use them multiple times.
See the following code:
I am using JSON for Modern C++ Version 2.1.1 with Microsoft Visual Studio 2015 Version 14.0.25431.01 Update 3 (regarding to your README the compiler should be okay). My operating system is Windows 7 SP1.
Thanks in advance!
The text was updated successfully, but these errors were encountered: