Name
File::DataClass::Storage::JSON - Read/write JSON data storage model
Synopsis
use Moo;
extends 'File::DataClass::Schema';
has '+storage_class' => default => 'JSON';
Description
Uses JSON::MaybeXS to read and write JSON files
Configuration and Environment
Defines the following attributes;
extn-
The extension appended to filenames. Defaults to .json
read_options-
This hash reference is used to customise the JSON decoder object used when reading the file. It defaults to
reboolifyfalse (causes booleans to be inflated to objects) andutf8false (the io object does the encoding). This filter would cause the data to be untainted (runningsuid). I shit you notfilter_json_object => sub { $_[ 0 ] } write_options-
This hash reference is used to customise the JSON encoder object used when writing the file. It defaults to
canonicaltrue (sorts the keys in the hashes),convert_blessedtrue (looks for and uses theTO_JSONmethod),prettytrue (uses whitespace for indentation), andutf8false (the io object does the encoding)
Subroutines/Methods
read_from_file
API required method. Calls "decode" in JSON::MaybeXS to parse the input
write_to_file
API required method. Calls "encode" in JSON::MaybeXS to generate the output
Diagnostics
None
Dependencies
Incompatibilities
There are no known incompatibilities in this module
Bugs and Limitations
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Using the module JSON::XS causes the round trip test to fail
Author
Peter Flanigan, <pjfl@cpan.org>
License and Copyright
Copyright (c) 2016 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE