cpanel_json_xs โ Cpanel::JSON::XS commandline utility
| Use Case | Command | Description |
|---|---|---|
| ๐ JSON Lint / Validate | cpanel_json_xs -t none <file.json | Validates a JSON file; exits with non-zero status on error |
| โจ Pretty-print JSON | cpanel_json_xs <src.json >pretty.json | Reads JSON and writes a pretty-printed version |
| ๐ Convert Storable to JSON | cpanel_json_xs -f storable-file <file | Reads a Storable file and outputs human-readable JSON |
| ๐ Convert Storable to YAML | cpanel_json_xs -f storable-file -t yaml <file | Reads Storable and outputs YAML |
| ๐งช Generate JSON from Perl | cpanel_json_xs -f none -e '$_ = [1, 2, 3]' | Outputs a Perl array as UTF-8 JSON |
| ๐ Fetch & pretty-print remote JSON | lwp-request URL | cpanel_json_xs | Pipes HTTP response JSON through the pretty-printer |
| ๐ฆ Extract torrent tracker list | cpanel_json_xs -f bencode -e '$_ = join "\n", map @$_, @{$_->{"announce-list"}}' -t string | Reads a bencoded torrent file and prints the tracker list |
| ๐ YAML format round-trip comparison | cpanel_json_xs -f yaml-xs -t yaml-tiny <META.yml >MYMETA.yml | Converts between YAML::XS and YAML::Tiny formats |
cpanel_json_xs [-v] [-f inputformat] [-t outputformat]
cpanel_json_xs converts between some input and output formats (one of them is JSON).
The default input format is "json" and the default output format is "json-pretty".
fromformat can be one of:
json โ a json text encoded, either utf-8, utf16-be/le, utf32-be/lejson-nonref โ json according to RFC 7159json-relaxed โ json with all relaxed optionsjson-unknown โ json with allow_unknownstorable โ a Storable frozen valuestorable-file โ a Storable file (Storable has two incompatible formats)bencode โ uses one of Net::BitTorrent::Protocol::BEP03::Bencode, Bencode or the broken Convert::Bencode, if available (used by torrent files, among others)clzf โ Compress::LZF format (requires that module to be installed)eval โ evaluate the given code as (non-utf-8) Perl, basically the reverse of "-t dump"yaml โ loose YAML (requires YAML)yaml-tiny โ loose YAML (requires YAML::Tiny or CPAN::Meta::YAML)yaml-xs โ strict YAML 1.2 (requires YAML::XS)yaml-syck โ YAML (requires YAML::Syck)cbor โ CBOR (via CBOR::XS)string โ do not attempt to decode the file datasereal โ Sereal (via Sereal::Decoder)none โ nothing is read, creates an "undef" scalar โ mainly useful with -etoformat can be one of:
json, json-utf-8 โ json, utf-8 encodedjson-pretty โ as above, but pretty-printed with sorted object keysjson-stringify โ as json-pretty with allow_stringifyjson-relaxed โ as json-pretty, but with the additional options ->allow_stringify->allow_blessed->convert_blessed->allow_unknown->allow_tags->stringify_infnan(1)json-utf-16le, json-utf-16be โ little endian/big endian utf-16json-utf-32le, json-utf-32be โ little endian/big endian utf-32storable โ a Storable frozen value in network formatstorable-file โ a Storable file in network format (Storable has two incompatible formats)bencode โ uses one of Net::BitTorrent::Protocol::BEP03::Bencode, Bencode or the broken Convert::Bencode, if available (used by torrent files, among others)clzf โ Compress::LZF formatyaml โ loose YAML (requires YAML)yaml-tiny โ loose YAML (requires YAML::Tiny or CPAN::Meta::YAML)yaml-xs โ strict YAML 1.2 (requires YAML::XS)yaml-syck โ YAML (requires YAML::Syck)dump โ Data::Dumpdumper โ Data::Dumperstring โ writes the data out as if it were a stringsereal โ Sereal (via Sereal::Encoder)none โ nothing gets written, mainly useful together with -edump instead.Evaluate perl code after reading the data and before writing it out again โ can be used to filter, create or extract data. The data that has been written is in $_, and whatever is in there is written out afterwards.
cpanel_json_xs -t none <isitreally.json
โ JSON Lint โ tries to parse the file isitreally.json as JSON โ if it is valid JSON, the command outputs nothing, otherwise it will print an error message and exit with non-zero exit status.
<src.json cpanel_json_xs >pretty.json
โจ Prettify the JSON file src.json to dst.json.
cpanel_json_xs -f storable-file <file
๐ฅ Read the serialized Storable file file and print a human-readable JSON version of it to STDOUT.
cpanel_json_xs -f storable-file -t yaml <file
๐ Same as above, but write YAML instead (not using JSON at all ๐)
cpanel_json_xs -f none -e '$_ = [1, 2, 3]'
๐งช Dump the perl array as UTF-8 encoded JSON text.
<torrentfile cpanel_json_xs -f bencode -e '$_ = join "\n", map @$_, @{$_->{"announce-list"}}' -t string
๐ Print the tracker list inside a torrent file.
lwp-request http://cpantesters.perl.org/show/Cpanel-JSON-XS.json | cpanel_json_xs
๐ Fetch the cpan-testers result summary "Cpanel::JSON::XS" and pretty-print it.
cpanel_json_xs -f yaml-xs -t yaml-tiny <META.yml >MYMETA.yml
cpanel_json_xs -f yaml-tiny -t yaml-xs <MYMETA.yml >XSMETA.yml
cpanel_json_xs -f yaml -t yaml <XSMETA.yml #BOOM!
Error: YAML_LOAD_ERR_BAD_MAP_ELEMENT
โ ๏ธ Compare YAML en- and decoders, and see that YAML::XS generates unparsable YAML <https://github.com/ingydotnet/yaml-libyaml-pm/issues/9>
Copyright (C) 2008 Marc Lehmann <json@schmorp.de> Copyright (C) 2016 Cpanel Inc
Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-04 07:17 @216.73.216.46
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)