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
|
|
|
|
|
|
|
#$Id$ |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Flow::From::JXML - deserialize flow from JSON+XML |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $f2 = create_flow( |
16
|
|
|
|
|
|
|
FromJXML => \$str2, |
17
|
|
|
|
|
|
|
Split => { |
18
|
|
|
|
|
|
|
Flow1 => create_flow( sub { push @fset1, @_ } ), |
19
|
|
|
|
|
|
|
Flow2 => create_flow( sub { push @fset2, @_ } ), |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
$f2->run(); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Flow::To::JXML - serialize flow to JSON+XML |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
package Flow::From::JXML; |
31
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
60
|
|
32
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
53
|
|
33
|
2
|
|
|
2
|
|
9
|
use JSON; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
34
|
2
|
|
|
2
|
|
185
|
use Flow::To::XML; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
39
|
|
35
|
2
|
|
|
2
|
|
8
|
use Data::Dumper; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
112
|
|
36
|
2
|
|
|
2
|
|
8
|
use base 'Flow::From::XML'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
898
|
|
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
|
|
|
|
|
|
|
|