CPANEL_JSON_XS(1)
π NAME π
cpanel_json_xs is the Cpanel::JSON::XS commandline utility, bestie β and this is the CPANEL_JSON_XS(1) page from the User Contributed Perl Documentation. Main character energy only. π
πΈ SYNOPSIS πΈ
cpanel_json_xs [-v] [-f inputformat] [-t outputformat]
π DESCRIPTION π
Okay so cpanel_json_xs converts between some input and output formats (one of them is JSON). No cap. β¨
The default input format is json, and the default output format is json-pretty. π«Ά
β¨ OPTIONS β¨
-vβ be slightly more verbose. π¬-ffromformat β read a file in the given format fromSTDIN.fromformatcan be one of:jsonβ a json text encoded, eitherutf-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 ofNet::BitTorrent::Protocol::BEP03::Bencode,Bencodeor the brokenConvert::Bencode, if available (used by torrent files, among others)clzfβCompress::LZFformat (requires that module to be installed)evalβ evaluate the given code as (non-utf-8) Perl, basically the reverse of-t dumpyamlβ loose YAML (requiresYAML)yaml-tinyβ loose YAML (requiresYAML::TinyorCPAN::Meta::YAML)yaml-xsβ strict YAML 1.2 (requiresYAML::XS)yaml-syckβ YAML (requiresYAML::Syck)cborβ CBOR (viaCBOR::XS)stringβ do not attempt to decode the file dataserealβ Sereal (viaSereal::Decoder)noneβ nothing is read, creates an"undef"scalar β mainly useful with-e
-ttoformat β write the file in the given format toSTDOUT.toformatcan 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 withallow_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 ofNet::BitTorrent::Protocol::BEP03::Bencode,Bencodeor the brokenConvert::Bencode, if available (used by torrent files, among others)clzfβCompress::LZFformatyamlβ loose YAML (requiresYAML)yaml-tinyβ loose YAML (requiresYAML::TinyorCPAN::Meta::YAML)yaml-xsβ strict YAML 1.2 (requiresYAML::XS)yaml-syckβ YAML (requiresYAML::Syck)dumpβData::DumpdumperβData::Dumperstringβ writes the data out as if it were a stringserealβ Sereal (viaSereal::Encoder)noneβ nothing gets written, mainly useful together with-e
Note thatData::Dumperdoesn't handle self-referential data structures correctly β usedumpinstead. π¬
-ecode β 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 read is in$_, and whatever is in there is written out afterwards. β¨
π¦ EXAMPLES π¦
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 π§
π AUTHOR π
- Copyright (C) 2008 Marc Lehmann
<json@schmorp.de> - Copyright (C) 2016 Cpanel Inc
Okay that's the page, bestie! This is the CPANEL_JSON_XS(1) manual from perl v5.42.0, dated 2026-10-15 β slay, bye! πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Cpanel-JSON-XS 4.800.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Cpanel-JSON-XS 4.800.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Cpanel-JSON-XS 4.800.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Cpanel-JSON-XS 4.800.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms