package Feed::Data::Parser::JSON;
use Moo;
extends 'Feed::Data::Parser::Base';
use Compiled::Params::OO qw/cpo/;
use Types::Standard qw/Object HashRef Str/;
use JSON;
our $validate;
BEGIN {
$valida
r' => (
default => sub {
my $self = shift;
my $content = $self->content_ref;
my $matches = JSON->new->decode($$content);
return { items => $matches };
},
);
has '+potential_fields' => (
de
:Strip->new();
my $string = $hs->parse(shift->raw);
return encode_utf8($string);
},
);
has 'json' => (
is => 'rw',
lazy => 1,
isa => Str,
default => sub {
return shift->text;
},
);
1;
tent =~ m/^([A-Za-z]+)\s*\:/) {
$tag = 'text';
} elsif ($$content =~ m/^\s*\[/) {
$tag = 'json';
} elsif ($$content =~ m/^([A-Za-z]+,)/) {
$tag = 'csv';
} elsif ($$content =~ m/---/) {
ed/i;
return 'Meta' if $tag =~ /^html/i;
return 'Text' if $tag =~ /^text/;
return 'JSON' if $tag =~ /^json/;
return 'CSV' if $tag =~ /^csv/;
return 'Table' if $tag =~ /^table/;
return 'YAM
g' if $self->stream =~ m{\<\?xml}xms;
return 'file' if $self->stream =~ m{(\.xml|\.html|\.txt|\.json|\.csv|\.yml)}xms;
}
);
sub open_stream {
my ($self) = $validate->open_stream->(@_);
my $type
:Parser::Base';
use Compiled::Params::OO qw/cpo/;
use Types::Standard qw/Object HashRef Str/;
use JSON;
use Text::CSV_XS qw/csv/;
our $validate;
BEGIN {
$validate = cpo(
get_value => [Object, Hash
', ', grep { $hs->parse($_) } @{ $content } : $content;
return $string;
}
);
has 'json' => (
is => 'rw',
lazy => 1,
default => sub {
return shift->raw;
},
);
1
e Feed::Data::Parser;
use Feed::Data::Stream;
use Feed::Data::Object;
use HTML::TableContent;
use JSON;
use Compiled::Params::OO qw/cpo/;
use XML::RSS::LibXML;
use Text::CSV_XS qw/csv/;
use YAML::XS q
Any, Optional->of(Str)],
raw => [Any, Optional->of(Str)],
text => [Any, Optional->of(Str)],
json => [Any, Optional->of(Str)],
yaml => [Any, Optional->of(Str)],
csv => [Any, Optional->of(Str)
tion || "Feed::Data",
%{$self->rss_channel}
);
my @render = $self->_convert_feed('generate', 'json');
for (@render) {
$rss->add_item(
%{$_}
);
}
return $rss->as_string;
}
sub _raw {
my