Skip to content

feat: Support comment removal#2

Merged
tymondesigns merged 3 commits intomainfrom
feat/comments
Feb 3, 2026
Merged

feat: Support comment removal#2
tymondesigns merged 3 commits intomainfrom
feat/comments

Conversation

@tymondesigns
Copy link
Contributor

@tymondesigns tymondesigns commented Feb 3, 2026

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\JsonRepair library. 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

  • Added InputSanitization trait (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.
  • Added StringHeuristics trait (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.
  • Added RepairLogging trait (src/Concerns/RepairLogging.php) for contextual debug logging during repair operations, including snippets of the JSON near the current parsing position.

Testing Improvements

  • Added a new comments dataset to tests/Datasets/JsonRepair.php to comprehensively test the removal of single-line, multi-line, and inline comments from JSON-like input.
  • Refactored the comment removal test in tests/Unit/JsonRepairerTest.php to use the new dataset, improving coverage and maintainability.

@tymondesigns tymondesigns marked this pull request as ready for review February 3, 2026 08:54
@tymondesigns tymondesigns merged commit 156b3b9 into main Feb 3, 2026
17 checks passed
@tymondesigns tymondesigns deleted the feat/comments branch February 11, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant