-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Iteration weirdness #842
Comments
Have you seen the |
@nlohmann Using iterator can solve it , but, do you have another way? or a faster way? I'm really sorry to trouble you, I'll appreciate your reply. Thanks. |
@nlohmann .key() and .value() are kinda weird from the C++ world. I think imitating std::map would be better personally. |
I did not find a better way. PRs welcome! |
@Exaeta Do you have an idea how to implement a better interface? |
Any news on this? |
I'm not super familiar with the implementation, but thinking about it, you'd probably lose the array vs object distinction if you did that, so maybe an obvious solution is not available. |
Related: #874 |
I'm closing this. Hopefully, #874 solves this issue. |
Feature Request
It seems that right now iterating over a
json
object iterates over it as though it was an array, which is counter intuitive from the C++ perspective, which you would expect to be iterated like astd::map
.I suggest
json::as_map()
andjson::as_array()
so that one can do:Both would return proxy objects (objects that contain a reference to the original, and different
begin()
andend()
functions.)The text was updated successfully, but these errors were encountered: