line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#=============================================================================== |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# DESCRIPTION: Deserialize to mixied XML and JSON |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# AUTHOR: Aliaksandr P. Zahatski, |
6
|
|
|
|
|
|
|
#=============================================================================== |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Flow::From::JXML - deserialize flow from JSON+XML |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $f2 = create_flow( |
15
|
|
|
|
|
|
|
FromJXML => \$str2, |
16
|
|
|
|
|
|
|
Split => { |
17
|
|
|
|
|
|
|
Flow1 => create_flow( sub { push @fset1, @_ } ), |
18
|
|
|
|
|
|
|
Flow2 => create_flow( sub { push @fset2, @_ } ), |
19
|
|
|
|
|
|
|
}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
$f2->run(); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Flow::To::JXML - serialize flow to JSON+XML |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
package Flow::From::JXML; |
30
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
84
|
|
31
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
65
|
|
32
|
2
|
|
|
2
|
|
9
|
use JSON; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
33
|
2
|
|
|
2
|
|
196
|
use Flow::To::XML; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
43
|
|
34
|
2
|
|
|
2
|
|
10
|
use Data::Dumper; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
129
|
|
35
|
2
|
|
|
2
|
|
10
|
use base 'Flow::From::XML'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
785
|
|
36
|
|
|
|
|
|
|
our $VERSION = '0.1'; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub begin { |
39
|
|
|
|
|
|
|
our $self = shift; |
40
|
|
|
|
|
|
|
$self->put_begin(@_); |
41
|
|
|
|
|
|
|
my $xfl = $self->{_xml_flow}; |
42
|
|
|
|
|
|
|
my %tags = ( |
43
|
|
|
|
|
|
|
flow => sub { shift; |
44
|
|
|
|
|
|
|
#clear UTF-X bit |
45
|
|
|
|
|
|
|
utf8::encode($_[0]) if utf8::is_utf8($_[0]); |
46
|
|
|
|
|
|
|
$self->put_flow( @{ decode_json( shift @_ ) } ) }, |
47
|
|
|
|
|
|
|
ctl_flow => |
48
|
|
|
|
|
|
|
sub { shift; |
49
|
|
|
|
|
|
|
#clear UTF-X bit |
50
|
|
|
|
|
|
|
utf8::encode($_[0]) if utf8::is_utf8($_[0]); |
51
|
|
|
|
|
|
|
$self->put_ctl_flow( @{ decode_json( shift @_ ) } ) } |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
$xfl->read( \%tags ); |
54
|
|
|
|
|
|
|
$xfl->close; |
55
|
|
|
|
|
|
|
return; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#sub flow { }; |
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|