Skip to content

uperl/JSON-LD

Repository files navigation

JSON::LD static

Load and dump JSON files

SYNOPSIS

use JSON::LD;

DumpFile("foo.json", { a => 1 });
my $data - LoadFile("foo.json:");

DESCRIPTION

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.

FUNCTIONS

All functions are exported by default.

DumpFile

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.

LoadFile

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.

CAVEATS

This module is a parody. However the struggle is real.

SEE ALSO

AUTHOR

Graham Ollis [email protected]

COPYRIGHT AND LICENSE

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.

About

Load and dump JSON files

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages