refactor: use JSON::MaybeXS for broader compatibility#26
Closed
Koan-Bot wants to merge 1 commit into
Closed
Conversation
Swap the hard dependency on JSON::XS (XS module, needs C toolchain) for JSON::MaybeXS, which transparently selects the best available backend: Cpanel::JSON::XS, JSON::XS, or JSON::PP (core since 5.14). Users with JSON::XS installed see zero behavior change. Environments without a C compiler now work out of the box with the pure-Perl fallback. The _build_json method keeps the same constructor chain — JSON::MaybeXS exposes the same ->new->utf8(0)->pretty(1) API. Closes #23. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6 tasks
Collaborator
Author
|
Superseded by #29 which consolidates this change (JSON::MaybeXS) with the Encode removal and JSON post refactor. |
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.
What
Swap the runtime dependency from
JSON::XS(XS, C toolchain required) toJSON::MaybeXS, which picks the best available backend at runtime.Why
Closes #23.
JSON::XSrequires a C compiler and dev headers to install, which blocks use in locked-down containers and minimal Docker images.JSON::MaybeXStransparently prefersCpanel::JSON::XS→JSON::XS→JSON::PP(core since 5.14), so:How
lib/Slack/WebHook.pm:use JSON::XS ()→use JSON::MaybeXS (),JSON::XS->new→JSON::MaybeXS->newdist.iniandcpanfile: runtime requires swapped accordinglyt/hooks.t: test imports swapped so the suite exercises the chosen backend (no separateJSON::XStest-only dep needed)The
_build_jsonconstructor chain (->new->utf8(0)->pretty(1)) is identical —JSON::MaybeXSexposes the same API.Testing
prove -Ilib t/hooks.t→ 48/48 pass locally (Cpanel::JSON::XS backend selected)Notes
This touches
lib/Slack/WebHook.pmandt/hooks.t, which will lightly conflict with PR #20 (JSON payload refactor). Conflict is trivial: both touch theuseline and one test decode call — resolution is "take both". Whichever merges first, the other rebases in ~2 lines.Quality Report
Changes: 4 files changed, 7 insertions(+), 7 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline