-
-
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
Documentation on operator[] behavior with missing keys #1855
Comments
The function (https://github.com/nlohmann/json/blob/develop/include/nlohmann/json.hpp#L3280) has a
Any proposal how to improve this? |
Documentation seems right. While accessing any key through operator [], we need to make sure that given key is in range, otherwise it will result in undefined behaviour and can also crash application. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Right now
operator[key]
is documented to create anull
key in the called upon json object shouldkey
not exist in that object, if the source object is NOTconst
. If the object isconst
,operator[]
returns the equivalent of*(map.cend())
.I think the documentation around this could be improved, as I would bet users are not fully aware of the behavioral differences depending on the
const
ness of the source object.I think the current behavior is fine, documentation could be improved to reflect it.
N/A
GCC 5 + RHEL7 as well as VC141/151 Win10 x64
develop
branch?Latest major version
The text was updated successfully, but these errors were encountered: