1Test2::Harness::Util::JUSsOeNr(3C)ontributed Perl DocumeTnetsatt2i:o:nHarness::Util::JSON(3)
2
3
4
6 Test2::Harness::Util::JSON - Utility class to help Test2::Harness pick
7 the best JSON implementation.
8
10 This package provides functions for encoding/decoding json, and uses
11 the best json tools available.
12
14 use Test2::Harness::Util::JSON qw/encode_json decode_json/;
15
16 my $data = { foo => 1 };
17 my $json = encode_json($data);
18 my $copy = decode_json($json);
19
21 $package = JSON()
22 This returns the JSON package being used by yath.
23
24 $bool = JSON_IS_PP()
25 True if yath is using JSON::PP.
26
27 $bool = JSON_IS_XS()
28 True if yath is using JSON::XS.
29
30 $bool = JSON_IS_CPANEL()
31 True if yath is using Cpanel::JSON::XS.
32
33 $bool = JSON_IS_CPANEL_OR_XS()
34 True if either JSON::XS or Cpanel::JSON::XS are being used.
35
36 $string = encode_json($data)
37 Encode data into json. String will be 1-line.
38
39 $data = decode_json($string)
40 Decode json data from the string.
41
42 $string = encode_pretty_json($data)
43 Encode into human-friendly json.
44
45 $string = encode_canon_json($data)
46 Encode into canon-json.
47
49 The source code repository for Test2-Harness can be found at
50 http://github.com/Test-More/Test2-Harness/.
51
53 Chad Granum <exodist@cpan.org>
54
56 Chad Granum <exodist@cpan.org>
57
59 Copyright 2020 Chad Granum <exodist7@gmail.com>.
60
61 This program is free software; you can redistribute it and/or modify it
62 under the same terms as Perl itself.
63
64 See http://dev.perl.org/licenses/
65
66
67
68perl v5.36.0 2022-09-08 Test2::Harness::Util::JSON(3)