NAME
Data::AnyXfer::From::JSON - transfer from json sources
SYNOPSIS
use Moo;
use MooX::Types::MooseLike::Base qw(:all);
extends 'Data::AnyXfer';
with 'Data::AnyXfer::From::JSON';
...
# Path::Class::File
has '+json' => ( default => sub { file('example.json'); } );
# Json string
has '+json' => ( default => sub { return '{"documents": [{"author": "Douglas Adams"}]'});
# Direct hash structure
has '+json' => ( default => sub { return { documents => [ { author => "Douglas Adams"}]}});
has '+documents_location' ( default => sub { [qw/data documents/] });
DESCRIPTION
The role configures Data::AnyXfer to use json as a data source.
ATTRIBUTES
json
Accepts hash refs, JSON strings or Path::Class::File to a json file.
The json structure must have a array where the documents for population are stored, the default location is "documents" : [], but this can be overriden with the attribute documents_location
.
documents_location
Defines the hash key where documents are stored in the json structure. Defaults to documents.
If documents are in a same layer then:
{
"buckets" : []
}
documents_location => [ 'buckets' ]
If documents are in a sub layer then:
{
"buckets": {
"data": {
"documents": [...]
}
}
}
documents_location => [qw/buckets data documents/]
COPYRIGHT
This software is copyright (c) 2019, Anthony Lucas.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.