NAME

JSON::Lines - Parse JSONLines with perl.

VERSION

Version 0.01

SYNOPSIS

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♣"]]}

DESCRIPTION

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/

EXPORT

jsonl

my $string = jsonl( canonical => 1, encode => 1, data => $data );

my $aoh = jsonl( decode => 1, data => $string )

SUBROUTINES/METHODS

new

Instantiate a new JSON::Lines object.

my $jsonl = JSON::Lines->new

encode

Encode a perl struct into a json lines string.

$jsonl->encode( %args );

decode

Decode a json lines string into a perl struct.

$jsonl->decode( %args );

add_line

Add a new line to the current JSON::Lines stream.

$jsonl->add_line($line);

clear_stream

Clear the current JSON::Lines stream.

$jsonl->clear_string;

AUTHOR

LNATION, <thisusedtobeanemail at gmail.com>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc JSON::Lines

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

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:

Around line 129:

Non-ASCII character seen before =encoding in '"7♣"],'. Assuming UTF-8