JSON::Lines - Parse JSONLines with perl.
Version 0.02
Quick summary of what the module does.
use JSON::Lines; my $jsonl = JSON::Lines->new(); my @data = ( ["Name", "Session", "Score", "Completed"], ["Gilbert", "2013", 24, true], ["Alexa", "2013", 29, true], ["May", "2012B", 14, false], ["Deloise", "2012A", 19, true] ); my $string = $jsonl->encode(@data); # ["Name", "Session", "Score", "Completed"] # ["Gilbert", "2013", 24, true] # ["Alexa", "2013", 29, true] # ["May", "2012B", 14, false] # ["Deloise", "2012A", 19, true] ... use JSON::Lines qw/jsonl/; my $data = [ { "name" => "Gilbert", "wins" => [ ["straight", "7♣"], ["one pair", "10♥"] ] }, { "name" => "Alexa", "wins" => [ ["two pair", "4♠"], ["two pair", "9♠"] ] }, { "name" => "May", "wins" => [] }, { "name" => "Deloise", "wins" => [ ["three of a kind", "5♣"] ] } ]; my $string = jsonl( canonical => 1, encode => 1, data => $data ); # {"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]} # {"name": "Alexa", "wins": [["two pair", "4♠"], ["two pair", "9♠"]]} # {"name": "May", "wins": []} # {"name": "Deloise", "wins": [["three of a kind", "5♣"]]}
JSON Lines is a convenient format for storing structured data that may be processed one record at a time. It works well with unix-style text processing tools and shell pipelines. It's a great format for log files. It's also a flexible format for passing messages between cooperating processes.
https://jsonlines.org/
my $string = jsonl( parse_headers => 1, encode => 1, data => $aoh ); my $aoa = jsonl( decode => 1, data => $string )
Instantiate a new JSON::Lines object.
my $jsonl = JSON::Lines->new
Encode a perl struct into a json lines string.
$jsonl->encode( $data );
Encode a perl struct into a json lines file.
$jsonl->encode_file($file, $data);
Decode a json lines string into a perl struct.
$jsonl->decode( $string );
Decode a json lines file into a perl struct.
$jsonl->decode_file( $file );
Add a new line to the current JSON::Lines stream.
$jsonl->add_line($line);
Clear the current JSON::Lines stream.
$jsonl->clear_string;
LNATION, <thisusedtobeanemail at gmail.com>
<thisusedtobeanemail at gmail.com>
Please report any bugs or feature requests to bug-json-lines at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=JSON-Lines. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-json-lines at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc JSON::Lines
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=JSON-Lines
CPAN Ratings
https://cpanratings.perl.org/d/JSON-Lines
Search CPAN
https://metacpan.org/release/JSON-Lines
This software is Copyright (c) 2020 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in '"7♣"],'. Assuming UTF-8
To install JSON::Lines, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JSON::Lines
CPAN shell
perl -MCPAN -e shell install JSON::Lines
For more information on module installation, please visit the detailed CPAN module installation guide.