Test2::Harness::Util::JSON(3pm)

Test2::Harness::Util::JSON3pm

Utility class to help test2::harness pick the best json implementation.

Usage

    use Test2::Harness::Util::JSON qw/encode_json decode_json/;
    my $data = { foo => 1 };
    my $json = encode_json($data);
    my $copy = decode_json($json);

Overview

This package provides functions for encoding/decoding json, and uses the best json tools available.

Exports

$package = JSON()

This returns the JSON package being used by yath.

$bool = JSON_IS_PP()

True if yath is using JSON::PP.

$bool = JSON_IS_XS()

True if yath is using JSON::XS.

$bool = JSON_IS_CPANEL()

True if yath is using Cpanel::JSON::XS.

$bool = JSON_IS_CPANEL_OR_XS()

True if either JSON::XS or Cpanel::JSON::XS are being used.

$string = encode_json($data)

Encode data into json. String will be 1-line.

$data = decode_json($string)

Decode json data from the string.

$string = encode_pretty_json($data)

Encode into human-friendly json.

$string = encode_canon_json($data)

Encode into canon-json.

Source

The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/.

Maintainers

Chad Granum <[email protected]>

Releases

2 releases since Debian 12 (Bookworm); the text changed 1 time.

  1. 12
  2. 13

Authors

Chad Granum <[email protected]>

From libtest2-harness-perl 1.000158-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.