view release on metacpan or search on metacpan
lib/JSON/PP.pm view on Meta::CPAN
Note that numerical precision has the same meaning as under Perl (so
binary to decimal conversion follows the same rules as in Perl, which
can differ to other languages). Also, your perl interpreter might expose
extensions to the floating point numbers of your platform, such as
infinities or NaN's - these cannot be represented in JSON, and it is an
error to pass those in.
JSON::PP (and JSON::XS) trusts what you pass to C<encode> method
(or C<encode_json> function) is a clean, validated data structure with
values that can be represented as valid JSON values only, because it's
not from an external data source (as opposed to JSON texts you pass to
C<decode> or C<decode_json>, which JSON::PP considers tainted and
doesn't trust). As JSON::PP doesn't know exactly what you and consumers
of your JSON texts want the unexpected values to be (you may want to
convert them into null, or to stringify them with or without
normalisation (string representation of infinities/NaN may vary
depending on platforms), or to croak without conversion), you're advised
to do what you and your consumers need before you encode, and also not
to numify values that may start with values that look like a number
(including infinities/NaN), without validating.
=back
=head2 OBJECT SERIALISATION
view all matches for this distribution
view release on metacpan or search on metacpan
Note that numerical precision has the same meaning as under Perl (so
binary to decimal conversion follows the same rules as in Perl, which
can differ to other languages). Also, your perl interpreter might expose
extensions to the floating point numbers of your platform, such as
infinities or NaN's - these cannot be represented in JSON, and it is an
error to pass those in.
=back
=head2 OBJECT SERIALISATION
view all matches for this distribution
view release on metacpan or search on metacpan
s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
s++;
}
sawinf = 1;
} else if (*s == 'N' || *s == 'n') {
/* XXX TODO: There are signaling NaNs and quiet NaNs. */
s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
s++;
sawnan = 1;
} else
view all matches for this distribution
view release on metacpan or search on metacpan
t/formats.t view on Meta::CPAN
# a signed 64-bit integer; see https://spec.openapis.org/api/format.json
int64 => +{ type => ['number', 'string'], sub => sub ($value) {
my $type = get_type($value);
return if not grep $type eq $_, qw(integer number string);
$value = Math::BigInt->new($value) if $type eq 'string';
return if $value eq 'NaN';
# using the literal numbers rather than -2**63, 2**63 -1 to maintain precision
$value >= Math::BigInt->new('-9223372036854775808') && $value <= Math::BigInt->new('9223372036854775807');
} },
},
);
t/formats.t view on Meta::CPAN
'"0"',
'"9223372036854775806"', # within bounds
'"9223372036854775807"', # maximum value
'"9223372036854775808"', # out of bounds
'"Inf"',
'"NaN"',
# number
'-9223372036854775809', # 13: out of bounds
'-9223372036854775808', # minimum value; difficult to use on most architectures without Math::BigInt
'-9223372036854775807', # within bounds
'0',
'9223372036854775806', # within bounds
'9223372036854775807', # maximum value
'9223372036854775808', # 19: out of bounds
# numeric Inf and NaN are not valid JSON
);
# note: results may vary on 32-bit architectures when not using Math::BigFloat
foreach my $decoder (
JSON::Schema::Modern::_JSON_BACKEND()->new->allow_nonref(1)->utf8(0),
view all matches for this distribution
view release on metacpan or search on metacpan
t/05_format_validation.t view on Meta::CPAN
# Valid doubles
ok($vd->validate(3.141592653589793)->is_valid, 'valid double: pi');
ok($vd->validate(1.7976931348623157e308)->is_valid, 'valid double: large');
# Special values as strings
ok($vf->validate('NaN')->is_valid || !$vf->validate('NaN')->is_valid, 'NaN handling defined');
ok($vf->validate('Infinity')->is_valid || !$vf->validate('Infinity')->is_valid, 'Infinity handling defined');
# Invalid
ok(!$vf->validate('hello')->is_valid, 'invalid float: text');
ok(!$vd->validate([1, 2, 3])->is_valid, 'invalid double: array');
view all matches for this distribution
view release on metacpan or search on metacpan
share/tv4.min.js view on Meta::CPAN
!function(a,b){"function"==typeof define&&define.amd?define([],b):"undefined"!=typeof module&&module.exports?module.exports=b():a.tv4=b()}(this,function(){function a(a){return encodeURI(a).replace(/%25[0-9][0-9]/g,function(a){return"%"+a.substring(3)...
view all matches for this distribution
view release on metacpan or search on metacpan
s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
s++;
}
sawinf = 1;
} else if (*s == 'N' || *s == 'n') {
/* XXX TODO: There are signaling NaNs and quiet NaNs. */
s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
s++;
sawnan = 1;
} else
view all matches for this distribution
view release on metacpan or search on metacpan
Note that numerical precision has the same meaning as under Perl (so
binary to decimal conversion follows the same rules as in Perl, which
can differ to other languages). Also, your perl interpreter might expose
extensions to the floating point numbers of your platform, such as
infinities or NaN's - these cannot be represented in JSON, and it is an
error to pass those in.
=back
=head2 OBJECT SERIALISATION
view all matches for this distribution
view release on metacpan or search on metacpan
lib/JSON/YAJL/ppport.h view on Meta::CPAN
s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
s++;
}
sawinf = 1;
} else if (*s == 'N' || *s == 'n') {
/* XXX TODO: There are signaling NaNs and quiet NaNs. */
s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
s++;
sawnan = 1;
} else
view all matches for this distribution
view release on metacpan or search on metacpan
lib/JSON/YY.pm view on Meta::CPAN
=over 4
=item * C<canonical> mode is accepted but not yet implemented (yyjson
has no sorted-key writer).
=item * NaN and Infinity values cannot be encoded (croaks).
=back
=head1 COOKBOOK
view all matches for this distribution
view release on metacpan or search on metacpan
lib/JSON5.pm view on Meta::CPAN
$perl_scalar = $json5->decode($json5_text)
JSON5 numbers and strings become simple Perl scalars. JSON5 arrays become
Perl arrayrefs and JSON5 objects become Perl hashrefs. C<true> becomes
C<1> (C<JSON::PP::true>), C<false> becomes C<0> (C<JSON::PP::false>),
C<NaN> becomes C<'NaN'>, C<Infinity> becomes C<'Inf'>, and
C<null> becomes C<undef>.
=head1 SEE ALSO
L<JSON::PP>
view all matches for this distribution
view release on metacpan or search on metacpan
example/js/jquery-1.2.6.js view on Meta::CPAN
// Force it by setting the zoom level
elem.zoom = 1;
// Set the alpha filter to set the opacity
elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
(parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
}
return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
"";
view all matches for this distribution
view release on metacpan or search on metacpan
eg/jslib/jquery-1.3.2.min.js view on Meta::CPAN
* http://docs.jquery.com/License
*
* Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
* Revision: 6246
*/
(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;thi...
/*
* Sizzle CSS Selector Engine - v0.9.3
* Copyright 2009, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
* More information: http://sizzlejs.com/
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Jasonify.pm view on Meta::CPAN
__PACKAGE__->set(
# Numify options
infinite => 'Infinity',
-infinite => '-Infinity',
nonnumber => 'NaN',
#num_sep => undef,
);
lib/Jasonify.pm view on Meta::CPAN
);
# key string sortby
# ======= ============== ===========
# "inf", '"Infinity"', "Infinity"
# "-inf", '"-Infinity"', "-Infinity"
# "nan", '"NaN"', "NaN"
return Jasonify::_key->new( $_, @$rep );
}
sub _objectify_via {
my $self = shift;
lib/Jasonify.pm view on Meta::CPAN
=item I<infinite> => B<Infinifty>,
=item I<-infinite> => B<-Infinifty>,
=item I<nonnumber> => B<NaN>,
How to encode the values for infinity, negative infinity, and not-a-number.
=back
view all matches for this distribution
view release on metacpan or search on metacpan
duk_config.h view on Meta::CPAN
#define DUK_DOUBLE_NAN NAN
#elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \
!defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX)
#define DUK_DOUBLE_NAN (0.0 / 0.0)
#else
/* In VBCC (0.0 / 0.0) results in a warning and 0.0 instead of NaN.
* In MSVC (VS2010 Express) (0.0 / 0.0) results in a compile error.
* Use a computed NaN (initialized when a heap is created at the
* latest).
*/
#define DUK_USE_COMPUTED_NAN
#define DUK_DOUBLE_NAN duk_computed_nan
#endif
duk_config.h view on Meta::CPAN
* http://llvm.org/bugs/show_bug.cgi?id=17788
*/
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_UCLIBC)
/* At least some uclibc versions have broken floating point math. For
* example, fpclassify() can incorrectly classify certain NaN formats.
* To be safe, use replacements.
*/
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_AIX)
/* Older versions may be missing isnan(), etc. */
duk_config.h view on Meta::CPAN
#undef DUK_USE_ATAN2_WORKAROUNDS
#if defined(DUK_F_MINGW)
#define DUK_USE_ATAN2_WORKAROUNDS
#endif
/* Rely as little as possible on compiler behavior for NaN comparison,
* signed zero handling, etc. Currently never activated but may be needed
* for broken compilers.
*/
#undef DUK_USE_PARANOID_MATH
view all matches for this distribution
view release on metacpan or search on metacpan
lib/JavaScript/Duktape/C/lib/duk_config.h view on Meta::CPAN
#define DUK_DOUBLE_NAN NAN
#elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \
!defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX)
#define DUK_DOUBLE_NAN (0.0 / 0.0)
#else
/* In VBCC (0.0 / 0.0) results in a warning and 0.0 instead of NaN.
* In MSVC (VS2010 Express) (0.0 / 0.0) results in a compile error.
* Use a computed NaN (initialized when a heap is created at the
* latest).
*/
#define DUK_USE_COMPUTED_NAN
#define DUK_DOUBLE_NAN duk_computed_nan
#endif
lib/JavaScript/Duktape/C/lib/duk_config.h view on Meta::CPAN
* http://llvm.org/bugs/show_bug.cgi?id=17788
*/
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_UCLIBC)
/* At least some uclibc versions have broken floating point math. For
* example, fpclassify() can incorrectly classify certain NaN formats.
* To be safe, use replacements.
*/
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_AIX)
/* Older versions may be missing isnan(), etc. */
lib/JavaScript/Duktape/C/lib/duk_config.h view on Meta::CPAN
#undef DUK_USE_ATAN2_WORKAROUNDS
#if defined(DUK_F_MINGW)
#define DUK_USE_ATAN2_WORKAROUNDS
#endif
/* Rely as little as possible on compiler behavior for NaN comparison,
* signed zero handling, etc. Currently never activated but may be needed
* for broken compilers.
*/
#undef DUK_USE_PARANOID_MATH
view all matches for this distribution
view release on metacpan or search on metacpan
lib/JavaScript/Embedded/C/lib/duk_config.h view on Meta::CPAN
#define DUK_DOUBLE_NAN NAN
#elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \
!defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX)
#define DUK_DOUBLE_NAN (0.0 / 0.0)
#else
/* In VBCC (0.0 / 0.0) results in a warning and 0.0 instead of NaN.
* In MSVC (VS2010 Express) (0.0 / 0.0) results in a compile error.
* Use a computed NaN (initialized when a heap is created at the
* latest).
*/
#define DUK_USE_COMPUTED_NAN
#define DUK_DOUBLE_NAN duk_computed_nan
#endif
lib/JavaScript/Embedded/C/lib/duk_config.h view on Meta::CPAN
* http://llvm.org/bugs/show_bug.cgi?id=17788
*/
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_UCLIBC)
/* At least some uclibc versions have broken floating point math. For
* example, fpclassify() can incorrectly classify certain NaN formats.
* To be safe, use replacements.
*/
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_AIX)
/* Older versions may be missing isnan(), etc. */
lib/JavaScript/Embedded/C/lib/duk_config.h view on Meta::CPAN
#undef DUK_USE_ATAN2_WORKAROUNDS
#if defined(DUK_F_MINGW)
#define DUK_USE_ATAN2_WORKAROUNDS
#endif
/* Rely as little as possible on compiler behavior for NaN comparison,
* signed zero handling, etc. Currently never activated but may be needed
* for broken compilers.
*/
#undef DUK_USE_PARANOID_MATH
view all matches for this distribution
view release on metacpan or search on metacpan
share/ext-3.4.1/adapter/ext/ext-base-debug.js view on Meta::CPAN
var pts = el.translatePoints(xy),
style = el.dom.style,
pos;
for (pos in pts) {
if (!isNaN(pts[pos])) {
style[pos] = pts[pos] + "px";
}
}
},
view all matches for this distribution
view release on metacpan or search on metacpan
lib/JavaScript/JSLint.pm view on Meta::CPAN
html_handlers: string, i: object, id: string, identifier: boolean,
identifier_function: string, iframe: object, img: object, immed: boolean,
implied_evil: string, in, indent: number, indexOf: *, infix_in: string,
init: function, input: object, ins: object, insecure_a: string,
isAlpha: function, isArray: function boolean, isDigit: function,
isExtensible: string, isFrozen: string, isNaN: string,
isPrototypeOf: string, isSealed: string, join: *, jslint: function boolean,
json: boolean, kbd: object, keygen: object, keys: *, label: object,
label_a_b: string, labeled: boolean, lang: string, lastIndex: string,
lastIndexOf: *, lbp: number, leading_decimal_a: string, led: function,
left: array, legend: object, length: *, 'letter-spacing': array,
lib/JavaScript/JSLint.pm view on Meta::CPAN
"and instead saw a function invocation.",
implied_evil: "Implied eval is evil. Pass a function instead of a string.",
infix_in: "Unexpected 'in'. Compare with undefined, or use the " +
"hasOwnProperty method instead.",
insecure_a: "Insecure '{a}'.",
isNaN: "Use the isNaN function to compare with NaN.",
label_a_b: "Label '{a}' on '{b}' statement.",
lang: "lang is deprecated.",
leading_decimal_a: "A leading decimal point can be confused with a dot: '.{a}'.",
missing_a: "Missing '{a}'.",
missing_a_after_b: "Missing '{a}' after '{b}'.",
lib/JavaScript/JSLint.pm view on Meta::CPAN
// ECMAScript standard.
standard = array_to_object([
'Array', 'Boolean', 'Date', 'decodeURI', 'decodeURIComponent',
'encodeURI', 'encodeURIComponent', 'Error', 'eval', 'EvalError',
'Function', 'isFinite', 'isNaN', 'JSON', 'Math', 'Number', 'Object',
'parseInt', 'parseFloat', 'RangeError', 'ReferenceError', 'RegExp',
'String', 'SyntaxError', 'TypeError', 'URIError'
], false),
standard_property_type = {
lib/JavaScript/JSLint.pm view on Meta::CPAN
}
break;
case 'false':
case 'function':
case 'Infinity':
case 'NaN':
case 'null':
case 'true':
case 'undefined':
case 'void':
case '(number)':
lib/JavaScript/JSLint.pm view on Meta::CPAN
case 'function':
case 'regexp':
warn('unexpected_a', node);
break;
default:
if (node.id === 'NaN') {
warn('isnan', node);
}
}
return node;
}
lib/JavaScript/JSLint.pm view on Meta::CPAN
warn('adsafe_a', x);
}
});
constant('false', 'boolean');
constant('Infinity', 'number');
constant('NaN', 'number');
constant('null', '');
reservevar('this', function (x) {
if (option.safe) {
warn('adsafe_a', x);
} else if (strict_mode && funct['(token)'].arity === 'statement' &&
lib/JavaScript/JSLint.pm view on Meta::CPAN
one_space();
particular = expression(0);
cases.forEach(find_duplicate_case);
cases.push(particular);
the_case.first.push(particular);
if (particular.id === 'NaN') {
warn('unexpected_a', particular);
}
no_space_only();
advance(':');
if (next_token.id !== 'case') {
view all matches for this distribution
view release on metacpan or search on metacpan
s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
s++;
}
sawinf = 1;
} else if (*s == 'N' || *s == 'n') {
/* XXX TODO: There are signaling NaNs and quiet NaNs. */
s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
s++;
sawnan = 1;
} else
view all matches for this distribution