package ETL::Yertl::Format::json;
our $VERSION = '0.044';
# ABSTRACT: JSON read/write support for Yertl
#pod =head1 SYNOPSIS
#pod
#pod =head1 DESCRIPTION
#pod
#pod =head1 SEE ALSO
#pod
#pod L<ETL::Ye
return (
[ 'JSON::XS' => 0 ],
[ 'JSON::PP' => 0 ],
);
}
sub _json_writer {
my ( $self ) = @_;
$self->{_json_writer} ||= do {
my $json = $self->{formatter_clas
ter_class} ne 'JSON::XS' ) {
$json->indent_length(3);
}
$json;
};
}
sub read_buffer {
my ( $self, $buffref, $eof ) = @_;
my $json = $self->{_json_reader} ||= $
data_exploration/>
#pod
#pod =cut
use ETL::Yertl;
use Net::Async::HTTP;
use URI;
use JSON::MaybeXS qw( decode_json );
use List::Util qw( first );
use IO::Async::Loop;
use Time::Piece ();
use Scalar::
r fetching metric '%s': " . $res->decoded_content . "\n", $metric;
}
my $result = decode_json( $res->decoded_content );
my @points;
for my $series ( map @{ $_->{series} }, @{ $result-
tent_type => 'text/plain' )->get;
if ( $res->is_error ) {
my $result = decode_json( $res->decoded_content );
die "Error writing metric '%s': $result->{error}\n";
p;
#pod
#pod my $loop = IO::Async::Loop->new;
#pod my $format = ETL::Yertl::Format->get( "json" );
#pod
#pod my $input = ETL::Yertl::FormatStream->new(
#pod read_handle => \*STDIN,
IO::Async::Loop;
my $loop = IO::Async::Loop->new;
my $format = ETL::Yertl::Format->get( "json" );
my $input = ETL::Yertl::FormatStream->new(
read_handle => \*STDIN,
forma
mats
#pod =head1 SYNOPSIS
#pod
#pod use ETL::Yertl::Format;
#pod my $json_format = ETL::Yertl::Format->get( "json" );
#pod my $default_format = ETL::Yertl::Format->get_default;
#pod
#pod
#pod other. By default, this is C<YAML>, but it can be set to C<JSON> by
#pod setting the C<YERTL_FORMAT> environment variable to C<"json">.
#pod
#pod Setting the default format to something besides Y
VERSION
version 0.044
=head1 SYNOPSIS
use ETL::Yertl::Format;
my $json_format = ETL::Yertl::Format->get( "json" );
my $default_format = ETL::Yertl::Format->get_default;
=head1 DESCRIP
've got serialized JSON in a database field, you can use C<jq> to deserialize
it:
ysql TESTDB 'SELECT json_field FROM table' # Query the database
| yto json
# Convert to JSON for jq
| js '.json_field | fromjson' # Inflate the JSON
| yfrom json # Convert ba
t/render_api.html>
#pod
#pod =cut
use ETL::Yertl;
use Net::Async::HTTP;
use URI;
use JSON::MaybeXS qw( decode_json );
use List::Util qw( first );
use IO::Async::Loop;
use Time::Piece ();
use Scalar::
my $metric = $query->{ metric };
my %form = (
target => $metric,
format => 'json',
noNullPoints => 'true',
);
if ( $query->{ start } ) {
$form{ from } =
r fetching metric '%s': " . $res->decoded_content . "\n", $metric;
}
my $result = decode_json( $res->decoded_content );
my @points;
for my $series ( @{ $result } ) {
for my $p
'
=head1 Converting Formats
Yertl uses YAML as its default output, but we can easily convert to JSON or CSV
using the L<yto utility|yto>.
$ ysql prod 'SELECT * FROM users' | yto csv
email,i
,1,preaction
postaction@example.com,2,postaction
$ ysql prod 'SELECT * FROM users' | yto json
{
"email" : "preaction@example.com",
"id" : "1",
"name" : "preaction"
mat
$ yfrom csv file.csv >work.yml
$ yfrom json file.json >work.yml
# Convert file to output format
$ yto csv work.yml
$ yto json work.yml
# Parse HTTP logs into documents
/Extract,_transform,_load>) for shells. It is
designed to accept data from multiple formats (CSV, JSON), manipulate them
using simple tools, and then convert them to an output format.
Yertl will have
=over 4
=item L<yfrom>
Convert incoming data (CSV, JSON) to Yertl documents.
=item L<yto>
Convert Yertl documents into another format (CSV, JSON).
=item L<ygrok>
Parse lines of text into Yertl d