Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robrwo/struct-flatten-template
Flatten arbitrary structures using a template
https://github.com/robrwo/struct-flatten-template
Last synced: 11 days ago
JSON representation
Flatten arbitrary structures using a template
- Host: GitHub
- URL: https://github.com/robrwo/struct-flatten-template
- Owner: robrwo
- Created: 2014-07-31T21:53:27.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-06-01T21:39:57.000Z (over 5 years ago)
- Last Synced: 2024-10-11T21:56:34.556Z (about 1 month ago)
- Language: Perl
- Size: 383 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
NAME
Struct::Flatten::Template - flatten data structures using a templateSYNOPSIS
use Struct::Flatten::Template;my $tpl = {
docs => [
{
key => \ { column => 0 },
sum => {
value => \ { column => 1 },
}
],
};my @data = ( );
my $hnd = sub {
my ($obj, $val, $args) = @_;my $idx = $args->{_index};
my $col = $args->{column};$data[$idx] ||= [ ];
$data[$idx]->[$col] = $val;
};my $data = {
docs => [
{ key => 'A', sum => { value => 10 } },
{ key => 'B', sum => { value => 4 } },
{ key => 'C', sum => { value => 18 } },
],
};my $p = Struct::Flatten::Template->new(
template => $tpl,
handler => $hnd,
);DESCRIPTION
This module is used for "flattening" complex, deeply-nested data
structures, such as those returned by an ElasticSearch aggregation
query.It is configured with a template that mirrors the data structure, where
some parts of the template contain information how to process the
corresponding parts of the data structure.SEE ALSO
The following alternative modules can be used to flatten hashes:Data::Hash::Flatten
Hash::FlattenAUTHOR
Robert Rothenberg, `'ACKNOWLEDGEMENTS
Foxtons, Ltd.LICENSE AND COPYRIGHT
Copyright 2014 Robert Rothenberg.This program is free software; you can redistribute it and/or modify it
under the terms of the the Artistic License (2.0). You may obtain a copy
of the full license at:http://www.perlfoundation.org/artistic_license_2_0