JSON_XS(1)
πΈ json_xs β JSON::XS commandline utility πΈ
(JSON_XS(1), from the User Contributed Perl Documentation) β okay so bestie, welcome to the manual page thatβs all about converting formats and being lowkey iconic β¨
β¨ NAME β¨
json_xs β the JSON::XS commandline utility. short, sweet, slay π
π SYNOPSIS π
json_xs [-v] [-f inputformat] [-t outputformat]
π¦ DESCRIPTION π¦
json_xs converts between some input and output formats (one of them is JSON). lowkey magic, highkey useful π«Ά
The default input format is json and the default output format is json-pretty. so if you just pipe stuff in, itβll pretty-print JSON back at you, no cap β¨
π OPTIONS π
-vβ Be slightly more verbose. just a lil extra chat, you know? π-ffromformat β Read a file in the given format fromSTDIN.
fromformat can be one of:
jsonβ a json text encoded, either utf-8, utf16-be/le, utf32-be/lecborβ CBOR (RFC 7049, CBOR::XS), a kind of binary JSONstorableβ a Storable frozen valuestorable-fileβ a Storable file (Storable has two incompatible formats)bencodeβ use 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 dumpyamlβ YAML format (requires that module to be installed)stringβ do not attempt to decode the file datanoneβ nothing is read, creates anundefscalar - mainly useful with-e
-ttoformat β Write the file in the given format toSTDOUT.
toformat can be one of:
jsonβ json, utf-8 encodedjson-utf-8β json, utf-8 encodedjson-prettyβ as above, but pretty-printedjson-utf-16leβ little endian utf-16json-utf-16beβ big endian utf-16json-utf-32leβ little endian utf-32json-utf-32beβ big endian utf-32cborβ CBOR (RFC 7049, CBOR::XS), a kind of binary JSONcbor-packedβ CBOR using extensions to make it smallerstorableβ a Storable frozen value in network formatstorable-fileβ a Storable file in network format (Storable has two incompatible formats)bencodeβ use Convert::Bencode, if available (used by torrent files, among others)clzfβ Compress::LZF formatyamlβ YAML::XS formatdumpβ Data::Dumpdumperβ Data::Dumperstringβ writes the data out as if it were a stringnoneβ nothing gets written, mainly useful together with-e
β οΈ Note that Data::Dumper doesn't handle self-referential data structures correctly - use dump instead.
-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 written is in$_, and whatever is in there is written out afterwards. literally a whole little Perl hook, bestie π§
π EXAMPLES π
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. cute lil validator, iconic π₯
<src.json json_xs >pretty.json
Prettify the JSON file src.json to dst.json. π
json_xs -f storable-file <file
Read the serialised Storable file file and print a human-readable JSON version of it to STDOUT. π«Ά
json_xs -f storable-file -t yaml <file
Same as above, but write YAML instead (not using JSON at all :) πΈ
json_xs -f none -e '$_ = [1, 2, 3]'
Dump the perl array as UTF-8 encoded JSON text. β¨
<torrentfile 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/JSON-XS.json | json_xs
Fetch the cpan-testers result summary "JSON::XS" and pretty-print it. π
π AUTHOR π
Copyright (C) 2008 Marc Lehmann <json@schmorp.de>
and thatβs the whole JSON_XS(1) moment, bestie: brought to you by perl v5.32.1, dated 2025-09-15, and signed with JSON_XS(1) energy π
β¨
π¦ where this page comes from
- centos-stream 9: perl-JSON-XS 1:4.04-1.el9 Β· GPL+ or Artistic
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms