NAME

Test::CPAN::Health::Reporter::JSON - Render a health report as a JSON document

SYNOPSIS

use Test::CPAN::Health::Reporter::JSON;

my $reporter = Test::CPAN::Health::Reporter::JSON->new(pretty => 1);
print $reporter->render($report);

DESCRIPTION

Serialises a Test::CPAN::Health::Report to a JSON document via JSON::MaybeXS. Suitable for piping to other tools, CI artifact storage, or consuming from scripts.

The emitted structure mirrors $report->as_hash.

render

PURPOSE

Serialise a Report to a JSON string.

API SPECIFICATION

INPUT

report  Test::CPAN::Health::Report  required

OUTPUT

Scalar string: valid JSON (UTF-8 encoded).

MESSAGES

Code  | Severity | Message                            | Resolution
------+----------+------------------------------------+---------------------
JSN01 | FATAL    | report must be a Report object     | Pass a Report instance

FORMAL SPECIFICATION

-- Z schema (placeholder) --
RenderOp
report : Report
json!  : String
-------------------------------------------------------
valid_json(json!)
decode_json(json!).overall_score = report.overall_score

SIDE EFFECTS

None.

USAGE EXAMPLE

my $json_str = $reporter->render($report);
write_file('report.json', $json_str);

AUTHOR

Nigel Horne, <njh at nigelhorne.com>

LICENSE AND COPYRIGHT

Copyright (C) 2025-2026 Nigel Horne.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.