Fix the parsing of nested sub-trees that use wildcards
Hey @halaxa! Long time since our last PR! π
Your package keeps improving, I love the support for multiple JSON pointers β€οΈ
While updating my package (based on yours), I noticed that some changes are interrupting the iteration of nested sub-trees at the first matching JSON object and ignore the remaining iterations. Which appears to be the issue flagged here: https://github.com/halaxa/json-machine/issues/78
This PR aims to bring the following changes:
- let indexes of JSON arrays be integer within the current path. This brings 2 benefits:
- accurate current path, JSON array indexes are actually integers
- avoid the use of regular expressions to perform checks against parts of the path
- fix how we compute the current path and current path wildcard
- currently these paths are not cleaned when the current level drops by 2 or more levels
- fix the parsing of nested sub-trees that use wildcards
- currently they are interrupted after the first iteration
- simplify and make the logic to compute the matching JSON pointer more accurate
- improve and add one more test for parsing nested sub-trees using wildcards
Hi, nice to see you again :) I'll be able to engage in about a week. Thank you very much for pushing it further.
(To be honest, I intend to rewrite the whole Parser from scratch, it's getting a little messy. But it's hard to say when I get to it...)
Hi @halaxa, no worries :) Do you plan to rewrite the parser before tackling this PR or you are thinking of rewriting it at a later stage?
I'm sorry for not replying. I'm currently a little busy with some voluntary work. I'm not sure when I get to this PR. But at the first look, I like that some of the messier code is gone π. In the meanwhile, could you rename "json pointer segment" to "reference token" for less confusion? It's the official designation: https://datatracker.ietf.org/doc/html/rfc6901#section-3. Thanks ;)
Although I know you didn't break it, making the build work could be a valuable meanwhile-contribution as well π.
No worries at all, take your time :)
I renamed the variables as you suggested, I guess the issue with the build is related to the conflict between the versions of PHP and composer:
Composer 2.3.0 dropped support for PHP <7.2.5 and you are running 7.0.33
You may consider to either add matrices to the build script or drop support for old versions of PHP
Merged the build fix from master with the fix for the composer version. make build works now.
Codecov Report
Base: 100.00% // Head: 100.00% // No change to project coverage :thumbsup:
Coverage data is based on head (
50aeebe) compared to base (21057a6). Patch coverage: 100.00% of modified lines in pull request are covered.
Additional details and impacted files
@@ Coverage Diff @@
## master #83 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 181 184 +3
===========================================
Files 17 17
Lines 528 526 -2
===========================================
- Hits 528 526 -2
| Impacted Files | Coverage Ξ | |
|---|---|---|
| src/Parser.php | 100.00% <100.00%> (ΓΈ) |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Thanks for finding the time to review and merge the PR! Do you reckon this fix can be tagged as 1.1.3? :)
Sure. I was just waiting for your response and maybe for #78 's as well.