mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
- JSON Library als Alternative zu JSON::XS eingebunden
git-svn-id: https://svn.fhem.de/fhem/trunk@4124 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
9eb2a0fa50
commit
55ee1d7b08
@ -26,10 +26,17 @@
|
||||
########################################################################################
|
||||
package main;
|
||||
|
||||
use JSON::XS;
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib qw(YAF);
|
||||
|
||||
# JSON::XS verwenden, falls nicht vorhanden auf JSON (in libraries enthalten) zurückfallen
|
||||
eval "use JSON::XS;";
|
||||
if ($@) {
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/FHEM/YAF/libs/json";
|
||||
use JSON;
|
||||
}
|
||||
|
||||
use YAF::YAFWidgets;
|
||||
use YAF::YAFConfig;
|
||||
|
||||
|
381
fhem/contrib/YAF/FHEM/YAF/libs/json/Changes
Normal file
381
fhem/contrib/YAF/FHEM/YAF/libs/json/Changes
Normal file
@ -0,0 +1,381 @@
|
||||
Revision history for Perl extension JSON.
|
||||
|
||||
## JSON version 2.xx #####################################################
|
||||
|
||||
From version 1.xx to 2.xx, JSON was totally rewritten.
|
||||
|
||||
* JSON becomes a wrapper to JSON::XS or JSON::PP!
|
||||
* objToJson() and jsonToObj() are obsoleted!
|
||||
* $JSON::* variables are no longer available!
|
||||
* JSON::Parser and JSON::Converter are deleted from the distribution!
|
||||
* JSONRPC* and Apache::JSONRPC are deleted from the distribution!
|
||||
Please check JSON::RPC (supports JSON-RPC protocol v1.1 and 1.0).
|
||||
|
||||
##########################################################################
|
||||
|
||||
2.61 Thu Oct 17 19:38:55 2013
|
||||
- fixed return/or in _incr_parse
|
||||
reported and patched by MAUKE, sprout and rjbs
|
||||
https://rt.cpan.org/Public/Bug/Display.html?id=86948
|
||||
|
||||
2.60
|
||||
- $json->is_xs, $json->is_pp was completely broken.
|
||||
pointed by rt#75867 and emceelam
|
||||
|
||||
2.59 Wed Jun 5 14:35:54 2013
|
||||
- PUREPERL_ONLY support was not supported...
|
||||
and finally remove all PP options from Makefile.PL.
|
||||
- recommend JSON::XS instead of conditionally requiring it
|
||||
patched by miyagaw
|
||||
( for example, $ cpanm --with-recommends JSON)
|
||||
- Hide more packages from PAUSE (and other stuff)
|
||||
patched by miyagawa
|
||||
|
||||
2.58 Thu May 23 09:04:37 2013
|
||||
- support PUREPERL_ONLY install option. (rt#84876)
|
||||
(PERL_ONLY and NO_XS are not yet removed)
|
||||
- stop installing JSON::XS automatically on Perl 5.18
|
||||
|
||||
2.57
|
||||
- t/x17_strage_overload.t didn't work correctly.
|
||||
|
||||
2.56 Sat Apr 6 09:58:32 2013
|
||||
- fixed t/x17_strage_overload.t (rt#84451 by Ricardo Signes)
|
||||
|
||||
2.55
|
||||
- update JSON::BackportPP version
|
||||
|
||||
2.54 Fri Apr 5 16:15:08 2013
|
||||
- fixed t/19_incr.t on perl >= 5.17.10 (wyant, rt#84154)
|
||||
pathced by mbeijen and modified with demerphq's patch
|
||||
- Fixed some spelling (by briandfoy)
|
||||
- fixed sppeling (by Perlover)
|
||||
- enhanced documents (Thanks to Justin Hunter and Olof Johansson)
|
||||
- changed backend module loading for overloaded object behavior
|
||||
(reported by tokuhirom)
|
||||
|
||||
2.53 Sun May 22 16:11:05 2011
|
||||
- made Makefile.PL skipping a installing XS question
|
||||
when set $ENV{PERL_ONLY} or $ENV{NO_XS} (rt#66820)
|
||||
|
||||
2.52 Sun May 22 15:05:49 2011
|
||||
- fixed to_json (pointed and patched by mmcleric in rt#68359)
|
||||
- backport JSON::PP 2.27200
|
||||
* fixed incr_parse docodeing string more correctly (rt#68032 by LCONS)
|
||||
|
||||
2.51 Tue Mar 8 16:03:34 2011
|
||||
- import JSON::PP 2.27105 as BackportPP
|
||||
- fixed documentations (pointed by Britton Kerin and rt#64738)
|
||||
|
||||
2.50 Mon Dec 20 14:56:42 2010
|
||||
[JSON]
|
||||
- stable release
|
||||
|
||||
2.49_01 Sat Nov 27 22:03:17 2010
|
||||
[JSON]
|
||||
- JSON::PP is split away JSON distributino for perl 5.14
|
||||
- JSON::backportPP is included in instead.
|
||||
|
||||
2.27 Sun Oct 31 20:32:46 2010
|
||||
[JSON::PP]
|
||||
- Some optimizations (gfx)
|
||||
[JSON::PP::5005]
|
||||
- added missing B module varibales (makamaka)
|
||||
|
||||
2.26 Tue Sep 28 17:41:37 2010
|
||||
[JSON::PP]
|
||||
- cleaned up code and enhanced sort option efficiency in encode.
|
||||
|
||||
2.25 Tue Sep 28 16:47:08 2010
|
||||
[JSON]
|
||||
- JSON::Backend::XS::Supportable always executed a needless process
|
||||
with JSON::XS backend. This made encode/decode a bit slower.
|
||||
|
||||
2.24 Mon Sep 27 10:56:24 2010
|
||||
[JSON::PP]
|
||||
- tweaked code.
|
||||
- optimized code in hash object encoding.
|
||||
|
||||
2.23 Sun Sep 26 22:08:12 2010
|
||||
[JSON::PP]
|
||||
- modified tied object handling in encode. it made encoding speed faster.
|
||||
pointed by https://rt.cpan.org/Ticket/Display.html?id=61604
|
||||
- modified t/e10_bignum.t
|
||||
for avoiding a warning in using Math::BigInt dev version
|
||||
|
||||
2.22 Wed Aug 25 12:46:13 2010
|
||||
[JSON]
|
||||
- added JSON::XS installing feature in Makefile.PL
|
||||
with cpan or cpanm (some points suggested by gfx)
|
||||
- check that to_json and from_json are not called as methods (CHORNY)
|
||||
[JSON::PP]
|
||||
- modified for -Duse64bitall -Duselongdouble compiled perl.
|
||||
11_pc_expo.t too. (these are patched by H.Merijn Brand)
|
||||
|
||||
2.21 Mon Apr 5 14:56:52 2010
|
||||
[JSON]
|
||||
- enhanced 'HOW DO I DECODE A DATA FROM OUTER AND ENCODE TO OUTER'
|
||||
- renamed eg/bench_pp_xs.pl to eg/bench_decode.pl
|
||||
- added eg/bench_encode.pl
|
||||
|
||||
2.20 Fri Apr 2 12:50:08 2010
|
||||
[JSON]
|
||||
- added eg/bench_pp_xs.pl for benchmark sample
|
||||
- updated 'INCREMENTAL PARSING' section
|
||||
[JSON::PP]
|
||||
- decode_prefix() didn't count a consumed text length properly.
|
||||
- enhanced XS compatibilty
|
||||
in the case of decoding a white space garbaged text.
|
||||
|
||||
2.19 Tue Mar 30 13:40:24 2010
|
||||
[JSON]
|
||||
- fixed typo (rt#53535 by Angel Abad)
|
||||
- added a recommendation
|
||||
refering to (en|de)code_json to pod (suggested by tokuhirom)
|
||||
- added 'HOW DO I DECODE A DATA FROM OUTER AND ENCODE TO OUTER' to pod.
|
||||
|
||||
2.18 Tue Mar 23 15:18:10 2010
|
||||
[JSON]
|
||||
- updated document (compatible with JSON::XS 2.29)
|
||||
[JSON::PP]
|
||||
- fixed encode an overloaded 'eq' object bug (reported by Alexey A. Kiritchun)
|
||||
- enhanced an error message compatible to JSON::XS
|
||||
|
||||
2.17 Thu Jan 7 12:23:13 2010
|
||||
[JSON]
|
||||
- fixed a problem caused by JSON::XS backend and support_by_pp option
|
||||
(rt#52842, rt#52847 by ikegami)
|
||||
[JSON::PP]
|
||||
- made compatible with JSON::XS 2.27
|
||||
- patched decode for incr_parse (rt#52820 by ikegami)
|
||||
- relaxed option caused an infinite loop in some condition.
|
||||
|
||||
2.16 Fri Oct 16 15:07:37 2009
|
||||
[JSON][JSON::PP]
|
||||
- made compatible with JSON::XS 2.26
|
||||
*indent adds a final newline
|
||||
- corrected copyrights in JSON::PP58.
|
||||
|
||||
2.15 Tue Jun 2 16:36:42 2009
|
||||
[JSON]
|
||||
- made compatible with JSON::XS 2.24
|
||||
- corrected copyrights in some modules.
|
||||
[JSON::PP]
|
||||
- modified incr_parse, pointed by Martin J. Evans (rt#46439)
|
||||
- deleted a meaningless code
|
||||
|
||||
2.14 Tue Feb 24 11:20:24 2009
|
||||
[JSON]
|
||||
- the compatible XS version was miswritten in document.
|
||||
|
||||
2.13 Sat Feb 21 17:01:05 2009
|
||||
[JSON::PP]
|
||||
- decode() didn't upgrade unicode escaped charcters \u0080-\u00ff.
|
||||
this problem was pointed by rt#43424 (Mika Raento)
|
||||
[JSON::PP::56]
|
||||
- fixed utf8::encode/decode emulators bugs.
|
||||
- defined a missing B module constant in Perl 5.6.0.
|
||||
(reported by Clinton Pierce)
|
||||
[JSON::PP::5005]
|
||||
- _decode_unicode() returned a 0x80-0xff value as UTF8 encoded byte.
|
||||
[JSON]
|
||||
- added a refference to JSON::XS's document "JSON and ECMAscript".
|
||||
- fixed a typo in the document (pointed by Jim Cromie).
|
||||
|
||||
2.12 Wed Jul 16 11:14:35 2008
|
||||
[JSON]
|
||||
- made compatible with JSON::XS 2.22
|
||||
|
||||
[JSON::PP]
|
||||
- fixed the incremental parser in negative nest level
|
||||
(pointed and patched by Yuval Kogman)
|
||||
|
||||
2.11 Tue Jun 17 14:30:01 2008
|
||||
[JSON::PP]
|
||||
- fixed the decoding process which checks number.
|
||||
regarded number like chars in Unicode (ex. U+FF11) as [\d].
|
||||
- enhanced error messages compatible to JSON::XS.
|
||||
|
||||
2.10 Tue Jun 3 18:42:11 2008
|
||||
[JSON]
|
||||
- made compatible with JSON::XS 2.21
|
||||
* updated the document.
|
||||
- added an item pointed by rt#32361 to the doc.
|
||||
|
||||
[JSON::PP] [JSON::PP58] [JSON::PP56] [JSON::PP5005]
|
||||
- made compatible with JSON::XS 2.21
|
||||
* added incr_reset
|
||||
- removed useless codes.
|
||||
|
||||
2.09 Sun Apr 20 20:45:33 2008
|
||||
[JSON]
|
||||
- made compatible with JSON::XS 2.2
|
||||
- changed pod section totally.
|
||||
|
||||
[JSON::PP] 2.20001
|
||||
- made compatible witg JSON::XS 2.2
|
||||
* lifted the log2 rounding restriction of max_depth and max_size.
|
||||
* incremental json parsing (EXPERIMENTAL).
|
||||
* allow_unknown/get_allow_unknown methods.
|
||||
- the version format was changed.
|
||||
X.YYZZZ => X.YY is the same as JSON::XS. ZZZ is the PP own version.
|
||||
- changed pod section totally.
|
||||
|
||||
2.08 Sat Apr 12 22:49:39 2008
|
||||
[JSON]
|
||||
- fixed JSON::Boolean inheritance mechanism.
|
||||
If the backend is XS with support_by_pp mode and using PP only
|
||||
support method, JSON::Boolean did not work correctly.
|
||||
Thanks to hg[at]apteryx's point.
|
||||
|
||||
[JSON::PP] 2.07
|
||||
- Now split into JSON::PP58 for Perl 5.8 and lator.
|
||||
- enhanced an error message compatible to JSON::XS
|
||||
did not croak when TO_JSON method returns same object as passed.
|
||||
|
||||
[JSON::PP58]
|
||||
- modified for Perls post 5.8.0 that don't have utf8::is_utf8.
|
||||
Thanks to Andreas Koenig.
|
||||
|
||||
2.07 Sat Feb 16 15:52:29 2008
|
||||
[JSON]
|
||||
- experimentally added -convert_blessed_universally to define
|
||||
UNIVERSAL::TO_JSON subroutine.
|
||||
|
||||
use JSON -convert_blessed_universally;
|
||||
$json->convert_blessed->encode( $blessed );
|
||||
|
||||
- and as_nonbleesed is obsoleted (not yet removed). OK?
|
||||
- fixed t/04_pretty.t.
|
||||
|
||||
2.06 Fri Feb 8 16:21:59 2008
|
||||
[JSON::PP] 2.06
|
||||
- enhanced the XS compatibility for pretty-printing
|
||||
and the indent handling was broken!
|
||||
|
||||
2.05 Tue Feb 5 13:57:19 2008
|
||||
[JSON::PP] 2.05
|
||||
- enhanced some XS compatibilities for de/encode.
|
||||
- now decode_error can dump high (>127) chars.
|
||||
- enhanced the XS combatilbity of the decoding error.
|
||||
- fixed the utf8 checker while decoding (is_valid_utf8).
|
||||
- implemented utf8::downgrade in JSON::PP56.
|
||||
- enhanced utf8::encode in JSON::PP56.
|
||||
- made utf8::downgrade return a true in JSON::PP5005.
|
||||
|
||||
2.04 Sat Jan 5 16:10:01 2008
|
||||
[JSON]
|
||||
- fixed a document typo pointed by kawasaki@annocpan
|
||||
- make DATA handle closed for error mssages in support_by_pp mode.
|
||||
- switched JSON::Backend::XS::Supportable wrapper de/encode
|
||||
to changing symbolic tables for croak messages and speed.
|
||||
- fixed support_by_pp setting
|
||||
|
||||
[JSON::PP] 2.04
|
||||
- enhanced the error message compatiblity to XS.
|
||||
|
||||
2.03 Fri Jan 4 14:10:58 2008
|
||||
[JSON]
|
||||
- fixed the description - Transition ways from 1.xx to 2.xx.
|
||||
$JSON::ConvBlessed compat => $json->allow_blessed->as_nonbleesed
|
||||
- support_by_pp supports 'as_nonbleesed' (experimental)
|
||||
- clean up the code for saving memory
|
||||
|
||||
[JSON::PP] 2.03
|
||||
- Now the allo_bignum flag also affects the encoding process.
|
||||
encode() can convert Math::BigInt/Float objects into JSON numbers
|
||||
- added as_nonblessed option (experimental)
|
||||
- cleaned up internal function names (renamed camel case names)
|
||||
|
||||
2.02 Wed Dec 26 11:08:19 2007
|
||||
[JSON]
|
||||
- Now support_by_pp allows to use indent_length()
|
||||
|
||||
[JSON::PP] 2.02
|
||||
- added get_indent_length
|
||||
|
||||
2.01 Thu Dec 20 11:30:59 2007
|
||||
[JSON]
|
||||
- made the object methods - jsonToObj and objToJson
|
||||
available for a while with warnings.
|
||||
|
||||
2.00 Wed Dec 19 11:48:04 2007
|
||||
[JSON]
|
||||
- new version!
|
||||
- modified Makefile.PL for broken Perls (when PERL_DL_NONLAZY = 1).
|
||||
|
||||
[JSON::PP] 2.0104
|
||||
- clean up the document.
|
||||
- use 'subs' instead of CORE::GLOBAL for fixing join() in 5.8.0 - 5.8.2
|
||||
- enhanced decoding error messages for JSON::XS compatibility.
|
||||
- jsonToObj and objToJson warn.
|
||||
|
||||
|
||||
1.99_05 Fri Dec 14 18:30:43 2007
|
||||
[JSON]
|
||||
- added a description about the Unicode handling to document.
|
||||
|
||||
[JSON::PP] (2.0103)
|
||||
- Now the JSON::PP56 unicode handling does not require Unicode::String.
|
||||
- Now JSON::PP5005 can de/enocde properly within the Perl 5.005 world.
|
||||
- decode() always utf8::decode()ed to strings.
|
||||
- decode() returned a big integer as string though the integer is
|
||||
smaller than it is so.
|
||||
- a bad know how - added the join() wrapper for Perl 5.8.0 - 5.8.2 bug.
|
||||
- JSON::PP56 encode() did not handle Unicode properly.
|
||||
- added a section about the unicode handling on Perls to JSON::PP doc.
|
||||
|
||||
1.99_04 Mon Dec 10 14:28:15 2007
|
||||
[JSON]
|
||||
- modified the tests and source for Perl 5.005
|
||||
|
||||
[JSON::PP] (2.0102)
|
||||
- modified some prototypes in JSON::PP5005.
|
||||
|
||||
1.99_03 Mon Dec 10 11:43:02 2007
|
||||
[JSON]
|
||||
- modified tests and document.
|
||||
in Perl5.8.2 or earlier, decoding with utf8 is broken because of
|
||||
a Perl side problem. (join() had a bug.)
|
||||
- modified Makefile.PL for Perl 5.005.
|
||||
in the version, 'require JSON' is fail....
|
||||
|
||||
[JSON::PP] (2.0102)
|
||||
- modified string decode function.
|
||||
- enhanced error messages for compatibility to JSON::XS.
|
||||
- enhanced utf8::decode emulator and unpack emulator in JSON::PP56.
|
||||
|
||||
1.99_02 Sun Dec 9 05:06:19 2007
|
||||
[JSON::PP] (2.0101)
|
||||
- decoding with utf8 was broken in Perl 5.10
|
||||
as the behaviour of unpack was changed.
|
||||
- added a fake in JSON::PP5005 (bytes.pm)
|
||||
- added the missing file JONS::PP::Boolean.pm
|
||||
|
||||
1.99_01 Sat Dec 8 12:01:43 2007
|
||||
[JSON]
|
||||
- released as version 2.0
|
||||
this module is incompatible to 1.xx, so check the document.
|
||||
|
||||
[JSON::PP] (2.01 from 0.97)
|
||||
- updated JSON::PP for compatible to JSON::XS 2.01
|
||||
- renamed from_json and to_json to decode_json and encode_json
|
||||
- added get_* to JSON::PP
|
||||
- deleted property() from JSON::PP
|
||||
- deleted strict() and added loose()
|
||||
- deleted disable_UTF8() and self_encode()
|
||||
- renamed singlequote to allow_singlequote
|
||||
- renamed allow_bigint to allow_bignum
|
||||
- max_depth and max_size round up their arguments.
|
||||
- added indent_length and sort_by
|
||||
|
||||
|
||||
## JSON version 1.xx
|
||||
|
||||
1.15 Wed Nov 14 14:52:31 2007
|
||||
- 1.xx final version.
|
||||
|
||||
0.09 Sat Apr 9 15:27:47 2005
|
||||
- original version; created by h2xs 1.22 with options
|
||||
-XA -b 5.5.3 -n JSON
|
||||
|
2292
fhem/contrib/YAF/FHEM/YAF/libs/json/JSON.pm
Normal file
2292
fhem/contrib/YAF/FHEM/YAF/libs/json/JSON.pm
Normal file
File diff suppressed because it is too large
Load Diff
2803
fhem/contrib/YAF/FHEM/YAF/libs/json/JSON/backportPP.pm
Normal file
2803
fhem/contrib/YAF/FHEM/YAF/libs/json/JSON/backportPP.pm
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@
|
||||
=head1 NAME
|
||||
|
||||
JSON::PP::Boolean - dummy module providing JSON::PP::Boolean
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# do not "use" yourself
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module exists only to provide overload resolution for Storable
|
||||
and similar modules. See L<JSON::PP> for more info about this class.
|
||||
|
||||
=cut
|
||||
|
||||
use JSON::backportPP ();
|
||||
use strict;
|
||||
|
||||
1;
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This idea is from L<JSON::XS::Boolean> written by
|
||||
Marc Lehmann <schmorp[at]schmorp.de>
|
||||
|
||||
=cut
|
||||
|
@ -0,0 +1,131 @@
|
||||
package # This is JSON::backportPP
|
||||
JSON::backportPP5005;
|
||||
|
||||
use 5.005;
|
||||
use strict;
|
||||
|
||||
my @properties;
|
||||
|
||||
$JSON::PP5005::VERSION = '1.10';
|
||||
|
||||
BEGIN {
|
||||
|
||||
sub utf8::is_utf8 {
|
||||
0; # It is considered that UTF8 flag off for Perl 5.005.
|
||||
}
|
||||
|
||||
sub utf8::upgrade {
|
||||
}
|
||||
|
||||
sub utf8::downgrade {
|
||||
1; # must always return true.
|
||||
}
|
||||
|
||||
sub utf8::encode {
|
||||
}
|
||||
|
||||
sub utf8::decode {
|
||||
}
|
||||
|
||||
*JSON::PP::JSON_PP_encode_ascii = \&_encode_ascii;
|
||||
*JSON::PP::JSON_PP_encode_latin1 = \&_encode_latin1;
|
||||
*JSON::PP::JSON_PP_decode_surrogates = \&_decode_surrogates;
|
||||
*JSON::PP::JSON_PP_decode_unicode = \&_decode_unicode;
|
||||
|
||||
# missing in B module.
|
||||
sub B::SVp_IOK () { 0x01000000; }
|
||||
sub B::SVp_NOK () { 0x02000000; }
|
||||
sub B::SVp_POK () { 0x04000000; }
|
||||
|
||||
$INC{'bytes.pm'} = 1; # dummy
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub _encode_ascii {
|
||||
join('', map { $_ <= 127 ? chr($_) : sprintf('\u%04x', $_) } unpack('C*', $_[0]) );
|
||||
}
|
||||
|
||||
|
||||
sub _encode_latin1 {
|
||||
join('', map { chr($_) } unpack('C*', $_[0]) );
|
||||
}
|
||||
|
||||
|
||||
sub _decode_surrogates { # from http://homepage1.nifty.com/nomenclator/unicode/ucs_utf.htm
|
||||
my $uni = 0x10000 + (hex($_[0]) - 0xD800) * 0x400 + (hex($_[1]) - 0xDC00); # from perlunicode
|
||||
my $bit = unpack('B32', pack('N', $uni));
|
||||
|
||||
if ( $bit =~ /^00000000000(...)(......)(......)(......)$/ ) {
|
||||
my ($w, $x, $y, $z) = ($1, $2, $3, $4);
|
||||
return pack('B*', sprintf('11110%s10%s10%s10%s', $w, $x, $y, $z));
|
||||
}
|
||||
else {
|
||||
Carp::croak("Invalid surrogate pair");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub _decode_unicode {
|
||||
my ($u) = @_;
|
||||
my ($utf8bit);
|
||||
|
||||
if ( $u =~ /^00([89a-f][0-9a-f])$/i ) { # 0x80-0xff
|
||||
return pack( 'H2', $1 );
|
||||
}
|
||||
|
||||
my $bit = unpack("B*", pack("H*", $u));
|
||||
|
||||
if ( $bit =~ /^00000(.....)(......)$/ ) {
|
||||
$utf8bit = sprintf('110%s10%s', $1, $2);
|
||||
}
|
||||
elsif ( $bit =~ /^(....)(......)(......)$/ ) {
|
||||
$utf8bit = sprintf('1110%s10%s10%s', $1, $2, $3);
|
||||
}
|
||||
else {
|
||||
Carp::croak("Invalid escaped unicode");
|
||||
}
|
||||
|
||||
return pack('B*', $utf8bit);
|
||||
}
|
||||
|
||||
|
||||
sub JSON::PP::incr_text {
|
||||
$_[0]->{_incr_parser} ||= JSON::PP::IncrParser->new;
|
||||
|
||||
if ( $_[0]->{_incr_parser}->{incr_parsing} ) {
|
||||
Carp::croak("incr_text can not be called when the incremental parser already started parsing");
|
||||
}
|
||||
|
||||
$_[0]->{_incr_parser}->{incr_text} = $_[1] if ( @_ > 1 );
|
||||
$_[0]->{_incr_parser}->{incr_text};
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
JSON::PP5005 - Helper module in using JSON::PP in Perl 5.005
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
JSON::PP calls internally.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Makamaka Hannyaharamitu, E<lt>makamaka[at]cpan.orgE<gt>
|
||||
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
Copyright 2007-2012 by Makamaka Hannyaharamitu
|
||||
|
||||
This library is free software; you can redistribute it and/or modify
|
||||
it under the same terms as Perl itself.
|
||||
|
||||
=cut
|
||||
|
@ -0,0 +1,173 @@
|
||||
package # This is JSON::backportPP
|
||||
JSON::backportPP56;
|
||||
|
||||
use 5.006;
|
||||
use strict;
|
||||
|
||||
my @properties;
|
||||
|
||||
$JSON::PP56::VERSION = '1.08';
|
||||
|
||||
BEGIN {
|
||||
|
||||
sub utf8::is_utf8 {
|
||||
my $len = length $_[0]; # char length
|
||||
{
|
||||
use bytes; # byte length;
|
||||
return $len != length $_[0]; # if !=, UTF8-flagged on.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub utf8::upgrade {
|
||||
; # noop;
|
||||
}
|
||||
|
||||
|
||||
sub utf8::downgrade ($;$) {
|
||||
return 1 unless ( utf8::is_utf8( $_[0] ) );
|
||||
|
||||
if ( _is_valid_utf8( $_[0] ) ) {
|
||||
my $downgrade;
|
||||
for my $c ( unpack( "U*", $_[0] ) ) {
|
||||
if ( $c < 256 ) {
|
||||
$downgrade .= pack("C", $c);
|
||||
}
|
||||
else {
|
||||
$downgrade .= pack("U", $c);
|
||||
}
|
||||
}
|
||||
$_[0] = $downgrade;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
Carp::croak("Wide character in subroutine entry") unless ( $_[1] );
|
||||
0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub utf8::encode ($) { # UTF8 flag off
|
||||
if ( utf8::is_utf8( $_[0] ) ) {
|
||||
$_[0] = pack( "C*", unpack( "C*", $_[0] ) );
|
||||
}
|
||||
else {
|
||||
$_[0] = pack( "U*", unpack( "C*", $_[0] ) );
|
||||
$_[0] = pack( "C*", unpack( "C*", $_[0] ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub utf8::decode ($) { # UTF8 flag on
|
||||
if ( _is_valid_utf8( $_[0] ) ) {
|
||||
utf8::downgrade( $_[0] );
|
||||
$_[0] = pack( "U*", unpack( "U*", $_[0] ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*JSON::PP::JSON_PP_encode_ascii = \&_encode_ascii;
|
||||
*JSON::PP::JSON_PP_encode_latin1 = \&_encode_latin1;
|
||||
*JSON::PP::JSON_PP_decode_surrogates = \&JSON::PP::_decode_surrogates;
|
||||
*JSON::PP::JSON_PP_decode_unicode = \&JSON::PP::_decode_unicode;
|
||||
|
||||
unless ( defined &B::SVp_NOK ) { # missing in B module.
|
||||
eval q{ sub B::SVp_NOK () { 0x02000000; } };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub _encode_ascii {
|
||||
join('',
|
||||
map {
|
||||
$_ <= 127 ?
|
||||
chr($_) :
|
||||
$_ <= 65535 ?
|
||||
sprintf('\u%04x', $_) : sprintf('\u%x\u%x', JSON::PP::_encode_surrogates($_));
|
||||
} _unpack_emu($_[0])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
sub _encode_latin1 {
|
||||
join('',
|
||||
map {
|
||||
$_ <= 255 ?
|
||||
chr($_) :
|
||||
$_ <= 65535 ?
|
||||
sprintf('\u%04x', $_) : sprintf('\u%x\u%x', JSON::PP::_encode_surrogates($_));
|
||||
} _unpack_emu($_[0])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
sub _unpack_emu { # for Perl 5.6 unpack warnings
|
||||
return !utf8::is_utf8($_[0]) ? unpack('C*', $_[0])
|
||||
: _is_valid_utf8($_[0]) ? unpack('U*', $_[0])
|
||||
: unpack('C*', $_[0]);
|
||||
}
|
||||
|
||||
|
||||
sub _is_valid_utf8 {
|
||||
my $str = $_[0];
|
||||
my $is_utf8;
|
||||
|
||||
while ($str =~ /(?:
|
||||
(
|
||||
[\x00-\x7F]
|
||||
|[\xC2-\xDF][\x80-\xBF]
|
||||
|[\xE0][\xA0-\xBF][\x80-\xBF]
|
||||
|[\xE1-\xEC][\x80-\xBF][\x80-\xBF]
|
||||
|[\xED][\x80-\x9F][\x80-\xBF]
|
||||
|[\xEE-\xEF][\x80-\xBF][\x80-\xBF]
|
||||
|[\xF0][\x90-\xBF][\x80-\xBF][\x80-\xBF]
|
||||
|[\xF1-\xF3][\x80-\xBF][\x80-\xBF][\x80-\xBF]
|
||||
|[\xF4][\x80-\x8F][\x80-\xBF][\x80-\xBF]
|
||||
)
|
||||
| (.)
|
||||
)/xg)
|
||||
{
|
||||
if (defined $1) {
|
||||
$is_utf8 = 1 if (!defined $is_utf8);
|
||||
}
|
||||
else {
|
||||
$is_utf8 = 0 if (!defined $is_utf8);
|
||||
if ($is_utf8) { # eventually, not utf8
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $is_utf8;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
JSON::PP56 - Helper module in using JSON::PP in Perl 5.6
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
JSON::PP calls internally.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Makamaka Hannyaharamitu, E<lt>makamaka[at]cpan.orgE<gt>
|
||||
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
Copyright 2007-2012 by Makamaka Hannyaharamitu
|
||||
|
||||
This library is free software; you can redistribute it and/or modify
|
||||
it under the same terms as Perl itself.
|
||||
|
||||
=cut
|
||||
|
72
fhem/contrib/YAF/FHEM/YAF/libs/json/MANIFEST
Normal file
72
fhem/contrib/YAF/FHEM/YAF/libs/json/MANIFEST
Normal file
@ -0,0 +1,72 @@
|
||||
Changes
|
||||
eg/bench_decode.pl
|
||||
eg/bench_encode.pl
|
||||
lib/JSON.pm
|
||||
lib/JSON/backportPP.pm
|
||||
lib/JSON/backportPP/Boolean.pm
|
||||
lib/JSON/backportPP/Compat5005.pm
|
||||
lib/JSON/backportPP/Compat5006.pm
|
||||
Makefile.PL
|
||||
MANIFEST
|
||||
META.yml Module meta-data (added by MakeMaker)
|
||||
README
|
||||
t/00_load.t
|
||||
t/00_pod.t
|
||||
t/01_utf8.t
|
||||
t/02_error.t
|
||||
t/03_types.t
|
||||
t/06_pc_pretty.t
|
||||
t/07_pc_esc.t
|
||||
t/08_pc_base.t
|
||||
t/09_pc_extra_number.t
|
||||
t/10_pc_keysort.t
|
||||
t/11_pc_expo.t
|
||||
t/12_blessed.t
|
||||
t/13_limit.t
|
||||
t/14_latin1.t
|
||||
t/15_prefix.t
|
||||
t/16_tied.t
|
||||
t/17_relaxed.t
|
||||
t/18_json_checker.t
|
||||
t/19_incr.t
|
||||
t/20_unknown.t
|
||||
t/21_evans_bugrep.t
|
||||
t/22_comment_at_eof.t
|
||||
t/99_binary.t
|
||||
t/_unicode_handling.pm
|
||||
t/e00_func.t
|
||||
t/e01_property.t
|
||||
t/e02_bool.t
|
||||
t/e03_bool2.t
|
||||
t/e04_sortby.t
|
||||
t/e05_esc_slash.t
|
||||
t/e06_allow_barekey.t
|
||||
t/e07_allow_singlequote.t
|
||||
t/e08_decode.t
|
||||
t/e09_encode.t
|
||||
t/e10_bignum.t
|
||||
t/e11_conv_blessed_univ.t
|
||||
t/e12_upgrade.t
|
||||
t/e13_overloaded_eq.t
|
||||
t/e14_decode_prefix.t
|
||||
t/e15_tie_ixhash.t
|
||||
t/e16_incr_parse_fixed.t
|
||||
t/e90_misc.t
|
||||
t/x00_load.t
|
||||
t/x02_error.t
|
||||
t/x12_blessed.t
|
||||
t/x16_tied.t
|
||||
t/x17_strange_overload.t
|
||||
t/xe01_property.t
|
||||
t/xe02_bool.t
|
||||
t/xe03_bool2.t
|
||||
t/xe04support_by_pp.t
|
||||
t/xe05_indent_length.t
|
||||
t/xe08_decode.t
|
||||
t/xe10_bignum.t
|
||||
t/xe11_conv_blessed_univ.t
|
||||
t/xe12_boolean.t
|
||||
t/xe19_xs_and_suportbypp.t
|
||||
t/xe20_croak_message.t
|
||||
t/xe21_is_pp.t
|
||||
META.json Module JSON meta-data (added by MakeMaker)
|
1566
fhem/contrib/YAF/FHEM/YAF/libs/json/README
Normal file
1566
fhem/contrib/YAF/FHEM/YAF/libs/json/README
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,8 @@
|
||||
DIR FHEM/YAF
|
||||
DIR FHEM/YAF/libs
|
||||
DIR FHEM/YAF/libs/json
|
||||
DIR FHEM/YAF/libs/json/JSON
|
||||
DIR FHEM/YAF/libs/json/JSON/backportPP
|
||||
DIR FHEM/YAF/widgets
|
||||
DIR FHEM/YAF/widgets/fs20easylamp
|
||||
DIR FHEM/YAF/widgets/fs20easylamp/www
|
||||
@ -19,7 +23,7 @@ DIR FHEM/YAF/www/smoothness/images
|
||||
DIR FHEM/YAF/www/img
|
||||
DIR FHEM/YAF/www/js
|
||||
DIR FHEM/YAF/xml
|
||||
UPD 2013-09-12_22:30:00 12062 FHEM/01_YAF.pm
|
||||
UPD 2013-10-28_18:30:00 12229 FHEM/01_YAF.pm
|
||||
UPD 2013-05-15_20:00:00 6590 FHEM/YAF/widgets/fs20st/fs20st.pm
|
||||
UPD 2013-08-14_21:30:00 7471 FHEM/YAF/widgets/fht80/fht80.pm
|
||||
UPD 2013-07-31_15:30:00 6534 FHEM/YAF/widgets/fhttk/fhttk.pm
|
||||
@ -58,3 +62,11 @@ UPD 2013-05-15_20:00:00 3641 FHEM/YAF/xml/xmlSchema.xsd
|
||||
UPD 2013-05-15_20:00:00 1690 FHEM/YAF/xml/yafConfig.xml
|
||||
UPD 2013-09-12_22:30:00 16597 FHEM/YAF/YAFConfig.pm
|
||||
UPD 2013-05-15_20:00:00 3439 FHEM/YAF/YAFWidgets.pm
|
||||
UPD 2013-10-28_18:30:00 12649 FHEM/YAF/libs/json/Changes
|
||||
UPD 2013-10-28_18:30:00 68658 FHEM/YAF/libs/json/JSON.pm
|
||||
UPD 2013-10-28_18:30:00 1353 FHEM/YAF/libs/json/MANIFEST
|
||||
UPD 2013-10-28_18:30:00 58186 FHEM/YAF/libs/json/README
|
||||
UPD 2013-10-28_18:30:00 82081 FHEM/YAF/libs/json/JSON/backportPP.pm
|
||||
UPD 2013-10-28_18:30:00 433 FHEM/YAF/libs/json/JSON/backportPP/Boolean.pm
|
||||
UPD 2013-10-28_18:30:00 2805 FHEM/YAF/libs/json/JSON/backportPP/Compat5005.pm
|
||||
UPD 2013-10-28_18:30:00 3829 FHEM/YAF/libs/json/JSON/backportPP/Compat5006.pm
|
||||
|
Loading…
Reference in New Issue
Block a user