The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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 reboolify false (causes booleans to be inflated to objects) and utf8 false (the io object does the encoding). This filter would cause the data to be untainted (running suid). I shit you not

   filter_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 canonical true (sorts the keys in the hashes), convert_blessed true (looks for and uses the TO_JSON method), pretty true (uses whitespace for indentation), and utf8 false (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

File::DataClass::Storage
JSON::MaybeXS

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) 2017 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