JSON_File - Tie a hash or an array to a JSON
version 0.004
use JSON_File; tie( my %data, 'JSON_File', 'data.json' ); $data{key} = "value"; # data directly stored in file print $data{key}; # data is always read from file, not cached $data{hash} = { attribute => "value" }; # DON'T set $data{hash}->{attribute} directly, it will not get saved tie( my @array, 'JSON_File', 'array.json' ); push @array, "value"; # you can enable functions of the JSON object: tie( my %other, 'JSON_File', 'other.json', pretty => 1, allow_unknown => 1, allow_blessed => 1, convert_blessed => 1, );
This module is allowing you to bind a perl hash or array to a file. The data is always read directly from the file and also directly written to the file. This means also that if you add several keys to the hash or several elements to the array, that every key and every element will let the complete json file be rewritten.
IRC
Join #sycontent on irc.perl.org. Highlight Getty for fast reaction :).
Repository
http://github.com/Getty/p5-json_file Pull request and additional contributors are welcome
Issue Tracker
http://github.com/Getty/p5-json_file/issues
Torsten Raudssus <torsten@raudss.us>
This software is copyright (c) 2013 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install JSON_File, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JSON_File
CPAN shell
perl -MCPAN -e shell install JSON_File
For more information on module installation, please visit the detailed CPAN module installation guide.