Conversation
This file contains hidden or 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
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.
This pull request introduces several new traits to the codebase to modularize and improve the handling of JSON input sanitization, string heuristics, and repair logging in the
Cortex\JsonRepairlibrary. It also expands the test suite to cover comment removal in JSON, and refactors existing tests to use new datasets. The most important changes are as follows:Core Functionality Enhancements
InputSanitizationtrait (src/Concerns/InputSanitization.php) with robust methods for extracting JSON from markdown/code blocks, removing single- and multi-line comments (while avoiding string literals and URL schemes), and extracting valid JSON objects/arrays from mixed input.StringHeuristicstrait (src/Concerns/StringHeuristics.php) to encapsulate logic for handling missing or embedded quotes in JSON strings, including detection of smart/curly quotes and distinguishing between embedded and terminating quotes.RepairLoggingtrait (src/Concerns/RepairLogging.php) for contextual debug logging during repair operations, including snippets of the JSON near the current parsing position.Testing Improvements
commentsdataset totests/Datasets/JsonRepair.phpto comprehensively test the removal of single-line, multi-line, and inline comments from JSON-like input.tests/Unit/JsonRepairerTest.phpto use the new dataset, improving coverage and maintainability.