Load and dump JSON files
use JSON::LD;
DumpFile("foo.json", { a => 1 });
my $data - LoadFile("foo.json:");
NOTE: Not to be confused with JSON-LD.
Ever want to load JSON from a file? Ever forget which module it is that you are
supposed to be using now? Is it JSON or JSON::PP or JSON::XS or
JSON::Syck or Cpanel::JSON::XS (how many Ns are in Cpanel? For some reason
I am bad at spelling) or JSON::MaybeXS or
JSON::XS::TheNextForkBecausePreviousMaintainerTurnedOutToBeADouche
.
Which file mode are you supposed to be using again? It's UTF-8 but I think I'm
supposed to read it as binary? I forget and I have a headache now.
This module is for you. It uses a similar interface to YAML for loading and dumping files.
All functions are exported by default.
DumpFile($filename, $data);
Dumps the data in $data
to $filename
as properly encoded JSON. If $data
cannot be represented as JSON or if there is an IO error it will throw an
exception.
my $data = LoadFile($filename);
Loads the data in JSON format from $filename
. If the JSON in $filename
is not properly formatted or encoded or if there is an IO error it will throw
an exception.
This module is a parody. However the struggle is real.
Graham Ollis [email protected]
This software is copyright (c) 2024 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.