forked from nlohmann/json
-
Notifications
You must be signed in to change notification settings - Fork 0
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
DRAFT: json start/end position implementation #1
Draft
sushshring
wants to merge
81
commits into
nlohmann-source
Choose a base branch
from
develop
base: nlohmann-source
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* 🚨 fix warning * 💚 update actions * 🚨 fix warning * 🚨 fix warning * 🚨 fix warning * 💚 update actions * 💚 update actions * 🚨 fix warning * 🚨 fix warning * 💚 update actions * 🚨 fix warning * 💚 update actions * 💚 update actions * 💚 update actions * 🚨 fix warning * 🚨 fix warning * 🚨 fix warning * 🚨 fix warning * 💚 update actions * 💚 update actions * 🚨 fix warning * 💚 update actions * 💚 update actions * 💚 update actions * 💚 update actions * 💚 update actions
…n#4372) * Make iteration_proxy_value model forward_iterator * Amalgamate * Suppress tidy warning
* 🚧 conversions for std::optional * 🏁 fix <optional> inclusion * 💚 overwork tests * Use JSON_HAS_CPP_17 only after it has been defined * ✅ update tests * 🏁 include right <optional> header * ♻️ do not include experimental headers * Add missing #endif after rebase * Fix failing test * Only define conversion to std::optional when JSON_USE_IMPLICIT_CONVERSION is disabled. * missing endif * Remove Wfloat-equal suppress * amalgamate * Move include of optional out of macro_scope; probably does not make sense to be there * Make clang-tidy happy * Suppress lint instead of changing to 'contains' --------- Co-authored-by: Niels Lohmann <[email protected]> Co-authored-by: Markus Palonen <[email protected]>
* 👷 add test for libstdc++ * 👷 add test for libstdc++ * 💚 add fixes from nlohmann#4490 * 💚 add fixes from nlohmann#4490
* Possible fix for nlohmann#4485 Throw's an exception when i is nullptr, also added a testcase for this scenario though most likely in the wrong test file.cpp * quick cleanup * Fix compile issues * moved tests around, changed exceptions, removed a possibly unneeded include * add back include <memory> for testing something * Ninja doesn't like not having a \n, at end of file, adding it back * update input_adapter file to deal with empty/null file ptr. * ran make pretty * added test for inputadapter * ran make amalgamate * Update tests/src/unit-deserialization.cpp Co-authored-by: Niels Lohmann <[email protected]> * Update tests/src/unit-deserialization.cpp Co-authored-by: Niels Lohmann <[email protected]> * Update input adapters.hpp with new includes * fix unabigious use of _, (there was a double declare) * did the amalagamate * rm duplicate includes * make amalgamate again * reorder * amalgamate * moved it above * amalgamate --------- Co-authored-by: Jordan <[email protected]> Co-authored-by: Niels Lohmann <[email protected]>
* Add docs and address other PR comments --------- Co-authored-by: Sush Shringarputale <[email protected]>
Signed-off-by: StepSecurity Bot <[email protected]>
* 💚 add step to build the documentation * 💚 add step to build the documentation
* 🚨 fix token permissions warnings * 🚨 fix token permissions warnings * 🚨 fix token permissions warnings
Signed-off-by: StepSecurity Bot <[email protected]>
* 💚 overwork cppcheck * 🔒 adjust permissions * 💚 fixes * 💚 fixes
--------- Co-authored-by: Sush Shringarputale <[email protected]>
… discarded values
* 🐛 set parents after insert call * 🚨 fix warning
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Abstract
Referring to discussion: 4455, this pull request introduces the implementation to retrieve the start and end positions of nested objects within the JSON during parsing.
Motivation
We have a service implementation with JSON schema where a field within the nested objects contains the hash value for that object. The service verifies the hash value of each of the nested objects before operating on the rest of the data sent.
For example, consider the following JSON:
Here, data_hash contains the hash of the object "details". In order to verify the data hash, we need to be able to retrieve the exact string that parsed out "details" including the spaces and newlines. Currently there is no way to achieve this using nlohmann/json parser.
Changes proposed
size_t start_position
andsize_t end_position
.Memory considerations
We considered storing substrings in the output JSON objects and sub-objects directly as well, however, considering the memory footprint increase that it would create, we opted for the option where only two size_t fields are stored per basic_json created.
Validation
We have added tests to the class_parser test suite that cover the following cases:
Since the change affects the sax_parser, for each of these test cases we validate scenarios where no callback is passed, a callback is passed that accepts all fields, and a callback is passed that filters specific fields.
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.