JSON_XS(1p)
β¨ JSON_XS(1p) β the manual, but make it cute β¨
okay bestie, welcome to the JSON_XS(1p) page from the User Contributed Perl Documentation collection π this is the official manual for json_xs and I'm about to explain the whole thing to you like we're texting at 2am, except every single fact is staying exactly where it is. no cap. π«Ά
πΈ NAME πΈ
json_xs β the commandline utility that ships with JSON::XS π
π SYNOPSIS π
json_xs [-v] [-f inputformat] [-t outputformat]
that's it. that's the whole vibe. three little flags and a dream β¨
π¦ DESCRIPTION π¦
okay so here's the tea: json_xs converts between some input and output formats, and one of them β you guessed it β is JSON π
the default input format is json and the default output format is json-pretty. so if you just pipe stuff in and out, it's gonna pretty-print your JSON for you. iconic behaviour honestly π
π OPTIONS π
-vβ be slightly more verbose. just a lil bit. a sprinkle. not a lot. π-ffromformat β read a file in the given format from STDIN π
fromformat can be one of these besties:
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β useConvert::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β 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 to STDOUT π¦
toformat can be one of these:
json,json-utf-8β json, utf-8 encodedjson-prettyβ as above, but pretty-printedjson-utf-16le,json-utf-16beβ little endian/big endian utf-16json-utf-32le,json-utf-32beβ little endian/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β useConvert::Bencode, if available (used by torrent files, among others)clzfβCompress::LZFformatyamlβYAML::XSformatdumpβData::DumpdumperβData::Dumperstringβ writes the data out as if it were a stringnoneβ nothing gets written, mainly useful together with-e
β οΈ heads up bestie: note thatData::Dumperdoesn't handle self-referential data structures correctly β usedumpinstead. this is a real one, don't get caught slipping π
-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. so you're basically remixing your own data in one line, main character energy fr fr β¨
π₯ 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. silent success, loud failure, the way it should be π
<src.json json_xs >pretty.json
prettify the JSON file src.json to dst.json. (yes the command writes to pretty.json, the description says dst.json, we don't make the rules, we just report them π)
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 :) β yes the manual literally put a smiley there and I respect it π«Ά
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 page bestie, no notes, you're now legally a json_xs expert π this lil slice of documentation came from perl v5.40.1, dated 2025-09-08, filed under JSON_XS(1p) β go convert something cute πβ¨π¦
π¦ where this page comes from
- debian trixie: libjson-xs-perl 4.040-1~deb13u1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libjson-xs-perl 4.040-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms