1CPANEL_JSON_XS(1)     User Contributed Perl Documentation    CPANEL_JSON_XS(1)
2
3
4

NAME

6       cpanel_json_xs - Cpanel::JSON::XS commandline utility
7

SYNOPSIS

9          cpanel_json_xs [-v] [-f inputformat] [-t outputformat]
10

DESCRIPTION

12       cpanel_json_xs converts between some input and output formats (one of
13       them is JSON).
14
15       The default input format is "json" and the default output format is
16       "json-pretty".
17

OPTIONS

19       -v  Be slightly more verbose.
20
21       -f fromformat
22           Read a file in the given format from STDIN.
23
24           "fromformat" can be one of:
25
26           json - a json text encoded, either utf-8, utf16-be/le, utf32-be/le
27           json-nonref - json according to RFC 7159
28           json-relaxed - json with all relaxed options
29           json-unknown - json with allow_unknown
30           storable - a Storable frozen value
31           storable-file - a Storable file (Storable has two incompatible
32           formats)
33           bencode - uses one of Net::BitTorrent::Protocol::BEP03::Bencode,
34           Bencode or the broken Convert::Bencode, if available (used by
35           torrent files, among others)
36           clzf - Compress::LZF format (requires that module to be installed)
37           eval - evaluate the given code as (non-utf-8) Perl, basically the
38           reverse of "-t dump"
39           yaml - loose YAML (requires YAML)
40           yaml-tiny - loose YAML (requires YAML::Tiny or CPAN::Meta::YAML)
41           yaml-xs - strict YAML 1.2 (requires YAML::XS)
42           yaml-syck - YAML (requires YAML::Syck)
43           cbor - CBOR (via CBOR::XS)
44           string - do not attempt to decode the file data
45           sereal - Sereal (via Sereal::Decoder)
46           none - nothing is read, creates an "undef" scalar - mainly useful
47           with "-e"
48       -t toformat
49           Write the file in the given format to STDOUT.
50
51           "toformat" can be one of:
52
53           json, json-utf-8 - json, utf-8 encoded
54           json-pretty - as above, but pretty-printed with sorted object keys
55           json-stringify - as json-pretty with allow_stringify
56           json-relaxed  - as json-pretty, but with the additional options
57               ->allow_stringify->allow_blessed->convert_blessed->allow_unknown
58               ->allow_tags->stringify_infnan(1)
59
60           json-utf-16le, json-utf-16be - little endian/big endian utf-16
61           json-utf-32le, json-utf-32be - little endian/big endian utf-32
62           storable - a Storable frozen value in network format
63           storable-file - a Storable file in network format (Storable has two
64           incompatible formats)
65           bencode - uses one of Net::BitTorrent::Protocol::BEP03::Bencode,
66           Bencode or the broken Convert::Bencode, if available (used by
67           torrent files, among others)
68           clzf - Compress::LZF format
69           yaml - loose YAML (requires YAML)
70           yaml-tiny - loose YAML (requires YAML::Tiny or CPAN::Meta::YAML)
71           yaml-xs - strict YAML 1.2 (requires YAML::XS)
72           yaml-syck - YAML (requires YAML::Syck)
73           dump - Data::Dump
74           dumper - Data::Dumper
75           string - writes the data out as if it were a string
76           sereal - Sereal (via Sereal::Encoder)
77           none - nothing gets written, mainly useful together with "-e"
78               Note that Data::Dumper doesn't handle self-referential data
79               structures correctly - use "dump" instead.
80
81       -e code
82           Evaluate perl code after reading the data and before writing it out
83           again - can be used to filter, create or extract data. The data
84           that has been written is in $_, and whatever is in there is written
85           out afterwards.
86

EXAMPLES

88          cpanel_json_xs -t none <isitreally.json
89
90       "JSON Lint" - tries to parse the file isitreally.json as JSON - if it
91       is valid JSON, the command outputs nothing, otherwise it will print an
92       error message and exit with non-zero exit status.
93
94          <src.json cpanel_json_xs >pretty.json
95
96       Prettify the JSON file src.json to dst.json.
97
98          cpanel_json_xs -f storable-file <file
99
100       Read the serialized Storable file file and print a human-readable JSON
101       version of it to STDOUT.
102
103          cpanel_json_xs -f storable-file -t yaml <file
104
105       Same as above, but write YAML instead (not using JSON at all :)
106
107          cpanel_json_xs -f none -e '$_ = [1, 2, 3]'
108
109       Dump the perl array as UTF-8 encoded JSON text.
110
111          <torrentfile cpanel_json_xs -f bencode -e '$_ = join "\n", map @$_, @{$_->{"announce-list"}}' -t string
112
113       Print the tracker list inside a torrent file.
114
115          lwp-request http://cpantesters.perl.org/show/Cpanel-JSON-XS.json | cpanel_json_xs
116
117       Fetch the cpan-testers result summary "Cpanel::JSON::XS" and pretty-
118       print it.
119
120           cpanel_json_xs -f yaml-xs -t yaml-tiny <META.yml   >MYMETA.yml
121           cpanel_json_xs -f yaml-tiny -t yaml-xs <MYMETA.yml >XSMETA.yml
122           cpanel_json_xs -f yaml -t yaml <XSMETA.yml #BOOM!
123           Error: YAML_LOAD_ERR_BAD_MAP_ELEMENT
124
125       Compare YAML en- and decoders, and see that YAML::XS generates
126       unparsable YAML
127       <https://github.com/ingydotnet/yaml-libyaml-pm/issues/9>
128

AUTHOR

130       Copyright (C) 2008 Marc Lehmann <json@schmorp.de> Copyright (C) 2016
131       Cpanel Inc
132
133
134
135perl v5.28.1                      2018-06-21                 CPANEL_JSON_XS(1)
Impressum