Docs: Fix wrong code usage in the Value access section of json_pointer.md
#4255
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The code usage demo in the Value access section of the JSON Pointer document does not work correctly
https://json.nlohmann.me/features/json_pointer/#value-access
json/docs/mkdocs/docs/features/json_pointer.md
Lines 62 to 78 in a259ecc
There are 3 mistakes in the code above:
(line 74) The json pointer
"/"
does not point to the root object. Instead, it points to the value with an empty string as the key at the root object. It should be replaced with json pointer""
json/tests/src/unit-json_pointer.cpp
Lines 91 to 92 in a259ecc
json/tests/src/unit-json_pointer.cpp
Lines 68 to 70 in a259ecc
(line 76) Incorrect usage of
nlohmann::basic_json::at
. It's a function and does not support the[]
operator(line 77) Incorrect usage of
nlohmann::basic_json::value
. It's a function and does not support the[]
operator. Additionally, the argument0
as the default value for thevalue
function is incorrectly placedThis PR resolves these 3 mistakes and makes the demo code work correctly
Pull request checklist
Read the Contribution Guidelines for detailed information.
include/nlohmann
directory, runmake amalgamate
to create the single-header filessingle_include/nlohmann/json.hpp
andsingle_include/nlohmann/json_fwd.hpp
. The whole process is described here.Please don't
#ifdef
s or other means.