Coder Social home page Coder Social logo

json3's Introduction

json3's People

Contributors

ansis avatar blackxored avatar bnjmnt4n avatar jdalton avatar oxyc avatar subtlegradient avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

json3's Issues

Minified version does not work with AMD loader

The v3.2.4 minified version will not load with an AMD loader like RequireJS. The problem seems to be the check for define.amd that Closure is renaming to define.a in the minified version:

p = "function" === typeof define && define.c //maps to line 8 in the source.

Thus the if (isLoader) fails on line 778 and never returns the JSON3 object.

You need a Closure extern here, or I think you can get around having to use Closure extern here by using the named property:

var isLoader = typeof define === "function" && define["amd"]

Which Closure will rewrite as define.amd in the minified version.

Prototype <= 1.6.1 Support

So...here's the story behind JSON 3 not supporting Prototype <= 1.6.1.

According to the spec entry for stringify, the toJSON method is used to obtain an alternative object for serialization. For example, Backbone's Model#toJSON returns a plain object containing the model's attributes, which is then serialized using the algorithm defined in the spec. For this behavior to make sense, toJSON should return a string, number, Boolean, array literal, or object literal—the only objects for which the serialization routine is explicitly defined.

Unfortunately, older versions of Prototype dictate that the toJSON method should return a pre-serialized JSON string. To make matters worse, it also defines toJSON methods on strings, dates, numbers, and arrays (but not booleans)—which means that stringify will call them to obtain a replacement value (a pre-serialized string), and then serialize that value. The result will always be a string literal, rather than a proper JSON structure.

This behavior is actually consistent with the spec, and using the native implementation will yield identical results. We can confirm this by running the following snippet in a browser that supports native JSON, and without JSON 3 loaded:

(function() {
  var script = document.createElement("script");
  script.src = "http://prototypejs.org/assets/2009/8/31/prototype.js";
  script.onload = function () {
    // This should be `true`.
    alert(JSON.stringify([1, 2, 3]) == "\"[1, 2, 3]\"");
  };
  document.body.appendChild(script);
}());

The spec doesn't account for a library that completely redefines how toJSON works, and catering to these versions of Prototype would require breaking compatibility with the spec. The objective of JSON 3 is twofold: provide a spec-complaint polyfill for older browsers, and fix bugs in the native JSON implementations of newer ones. I'm afraid that fixing a buggy, dated library (1.6.1 was released in September 2009; 1.7, which corrects the issues, was released in November 2010) would fall outside the scope of this project.

A Note on Object.toJSON: The Object.toJSON method provided by Prototype is not an appropriate fallback for JSON.stringify—it doesn't support the filter or whitespace arguments, and will recurse indefinitely when attempting to serialize cyclic structures. Additionally, Prototype's date serialization is broken (it doesn't support extended years or milliseconds, for example), and doesn't work around the bugs present in Opera >= 10.53.

The only viable option that I can see is to monkey-patch Prototype. There are two significant problems with this approach as well. First, it would involve increasing the size and complexity of the source for a very specific audience. Secondly, even if all of Prototype's buggy methods could be monkey-patched, nothing can be done about third-party code. Remember that Prototype redefines the behavior of toJSON—which means that third-party code that relies on this behavior will break if the library is patched. It's a less than stellar solution.

I'm certainly open to discussing this, but let's keep in mind that any solution we come up with is likely to be an egregious hack. For that reason, I'd like to tread cautiously before implementing any kind of a patch (@tobie, @savetheclocktower—if you have the time and inclination, I'd love to hear any thoughts that you may have about this).

Incorrect JSON.stringify() sniffing

json3/lib/json3.js:13 uses "A" as the key. That really ought to be "result" to give native implementations a chance to pass on the preconditions that this library imposes.

Remove detailed `SyntaxError` messages from `JSON.parse`

TL;DR: JSON.parse and JSON.stringify currently provide detailed error messages. This behavior is implementation-dependent, and increases the file size. Shall I remove these messages?

Currently, the JSON.parse implementation provides very specific syntax error messages—"Illegal octal literal," "Invalid {Unicode} escape sequence in string," "Expected end-of-file," ""A single colon (:) must separate each object property name from the value," and so on (JSON.stringify also emits the message, "Cyclic structures cannot be serialized"). Unfortunately, this increases the file size, for a potentially inconsequential gain.

I can't imagine that this feature is well-known, and native parse implementations are typically much less specific: Chrome uses the catch-all "Unexpected end of input" and "Unexpected token: X" messages for many errors, Safari attempts to provide some additional details, and Firefox falls back to "Unexpected character." Likewise, JSON 2 only emits a generic syntax error if the JSON source string cannot be parsed. It's clear that relying on implementation-dependent error messages is unwise.

The only use case that I can contrive for the current behavior is a primitive syntax validator, though, because JSON 3 throws the first syntax error that it encounters, it's not particularly useful.

Removing the messages will reduce the code size to 3 KB (minified and gzip-ed), which was the size of v3.0. Without gzip, the size of the minified version will be reduced from 8.8 KB to 7.9 KB. The difference isn't drastic, but certainly noticeable, especially given the fact that JSON 2 is 1.3 KB.

Would love to obtain some feedback on this. Should the detailed error messages be retained, or can they be removed in the next point release (v3.2.1)?

Opera Testsuite Failures

I don't know how correct it is, but Opera has a comprehensive JSON test suite. I used it a few years ago to pinpoint IE8's JSON bugs. When I ran JSON3 against the Opera tests, there were 3 failures.

The Opera tests claim that JSON.stringify(Math, ["PI"]); should equal {"PI":3.141592653589793} which it does in Firefox 11 Windows. JSON3 returns {}. The other 2 failures were related to stringify-ing arguments which may be open to interpretation as far as the spec goes. Also note that those Opera tests show Firefox has some failures that JSON3 does not; JSON3 Rocks!

Testsuite URL
http://testsuites.opera.com/JSON/runner.htm

Failures:
JSON.stringify() whitelist includes dontEnum properties
http://testsuites.opera.com/JSON/correctness/scripts/045.js

JSON.stringify() and the arguments array
http://testsuites.opera.com/JSON/integration/scripts/005.js

JSON.stringify() and the arguments array - with replacer whitelist
http://testsuites.opera.com/JSON/integration/scripts/006.js

Enhance `noConflict` to restore previous `JSON3` object

Hey there,

I'm using JSON3 as a dependency in a browser-based third-party JS library. My goal is to prevent potential conflicts as much as possible, so noConflict has come in handy. Thanks!

One enhancement that I'd like your feedback on is taking noConflict one step further and restoring the global JSON3 object that's exposed to the previous value. This way, if the page including my library already uses an older/newer version of JSON3, there's no chance for potential conflict. (Duh, you all probably don't need that explained. 😄)

What do you think? I may try adding this enhancement if you're cool with the idea.

Thanks again for your work on this!

jQuery.parseJSON of an array fails with json3 but works with json2

Hi,
Given this line:
jQuery.parseJSON('["states.stateListing", "states.clientListing"]')

json3: throws an exception
json2: correctly parses it as an array

Browser: IE10 IE7 Browser Mode, IE7 Document Mode
jQuery version: 1.9.1

Sorry if this is documented somewhere else.
Philip

Date serialization's timezone handling is broken (seems hardcoded to UTC-06:00)

The stringify date tests fail in every single browser I tested it in (Firefox 10, Chrome 16, Safari 5.1, Opera 11.61, Camino 2.1.2 [~Firefox 3.6]):

Dates are serialized using the simplified date time string format
    Expected: "\"1994-07-03T06:00:00.000Z\""
    Actual: "\"1994-07-02T22:00:00.000Z\""
The date time string should conform to the format outlined in the spec
    Expected: "\"1993-06-02T08:10:28.224Z\""
    Actual: "\"1993-06-02T00:10:28.224Z\""

This is on OSX 10.6.8 in the Central European Timezone (UTC+01:00).

There are 8h difference between the expected time and the actual time, on both dates the Date object uses CEST (UTC+02:00). I'd expect things to break even more as the timezone is moved further east (e.g. in the Australian timezones, between UTC+08:00 and UTC+11:00) on the testing machine.

Remove Prototype <= 1.6.1 Support

Prototype <= 1.6.1 support was added quite some time ago, in #8, back when many people were still using outdated versions of Prototype. However, the current Prototype version is 1.7.2 (released this year), and the toJSON bug was fixed in 1.7 (released in 2010).

However, if we intend to use a replacer function to serialise Dates (as in #65), it might be difficult to ensure that the toJSON property of Strings, Numbers, Arrays and Dates are not called. Thus, I would recommend we remove support for Prototype <= 1.6.1.

@kitcambridge what do you think?

JSON3 uses a lot of memory in Windows Mobile

Hi!

I am developing a Windows Mobile 6.5 application (not windows phone, windows mobile), and i use a Webview and a lot of JSON object. I had used json2 but i had quite problems with this one.

I found this amazing library which resolves all the problems that i had with json2.

However, this library wastes a lot of memory so in five or six minutes my app haven't memory and throws OutOfMemory. json2 doesn't use so much memory so....is there any reason for this??

Thanks for your answer!

PD: Sorry for my bad english.

Minor: typo in JSON3 code documentation

A minor documentation regression, somewhere between version 3.2.5 and 3.3.1, seems to have slipped and a typo, "objectgs", was born around line 235 (as of this writing):

// Capture and break the objectgs prototype chain (see section 8.6.2
// of the ES 5.1 spec). The parenthesized expression prevents an
// unsafe transformation by the Closure Compiler.

New release for Bower

It looks like Bower package was released before ignore option was added to bower.json config and so the current json3 Bower package takes a whopping 6MB.

Bower doesn't have any kind of lock/shrinkwrap mechanism, so some people might want to add all packages to the repo to avoid surprises when deploying to ci/production servers.

New release should probably solve this problem.

Native stringify is not being used (at all!) in Firefox due to a (Fx) bug in date serialization

Due to Firefox bug 730831, Firefox is currently causing the date test to fail and, therefore, always triggering the script-based stringify instead of the native implementation.

Although this was already triaged to be a Firefox issue, this was created in order to:

  • Act as a reminder, while the Firefox bug is fixed
// Firefox misses the positive sign - see http://bugzil.la/730831
  • Maybe consider creating or providing a workaround to allow Firefox to use its native stringify instead of the script-based emulation
    • when date parsing is not being used or dates are within reasonable timespans, users are currently getting a performance hit without a (good) reason
  • Allow to cross-link both issues so that anyone interested can easily keep up

JSON.stringify doesn't work on IDispatch wrappers in JScript

If I get an object in Internet Explorer's JScript engine from e.g. an add-on written in C++, I don't get a native JavaScript object. Instead, I get a wrapper that uses Microsoft's IDispatch interface to duplicate the behavior of a native JS object. For example, the hasOwnProperty method will use some IDispatch method (maybe GetIDsOfNames?) to return the correct value.

In your library, you cache the value of Object.prototype.hasOwnProperty in a variable called isProperty that is reused for all the objects that are passed into the stringify() method. As a result, an object received via IDispatch will use the wrong method (i.e. the default hasOwnProperty instead of the special IDispatch hasOwnProperty). This causes the library to think that it should serialize the object's "constructor" property since isProperty.call(object, "constructor") erroneously returns true. The end result is a type error since it thinks the object has a cyclic structure.

The right solution might be to check in forEach whether the object is an IDispatch wrapper and always use its hasOwnProperty method if it is. I'm not sure how to determine this, but if this sounds like a viable approach to you, I can have a look around and propose a patch.

Use the has API

Use the has API instead of stringifySupported and parseSupported in order to take advantage of has-aware AMD optimizers, like r.js and dojo.

function has( id ){
    if( id === 'json' ){
        return !!JSON;
    } else if( id === 'json-stringify' ){
        return typeof JSON.stringify === "function";
    } else if( id === 'json-parse' ){
        return typeof JSON.parse === "function";
    } else {
        return false;
    }
}
if( has( 'json-stringify' ) ){
...
}
if( has( 'json-parse' ) ){
...
}

IE failing JSON3 Parse

Hi,

I am using JSON3 and in Internet Explorer the Parse method fails the feature tests (as discussed in other posts here), I am just wondering if someone could explain what impact it could have if I use JSON2, which would use the native parsing in IE?

I assume that it could cause some issue at some point, I just don't know what it would be? Ideally I want to use the native IE parse method because the performance improvement is fairly significant, I just don't want to run into problems down the road.

Thanks,

Iain

The minified script always has parseSupported = false because of a key that gets wrongly changed by the minifier.

https://github.com/bestiejs/json3/blob/gh-pages/lib/json3.js#L130:

if ((parseSupported = value.A.length == 5 && value.A[0] == 1)) {

Minified code:

if(a=d.a.length==5&&d.a[0]==1){

The A key gets transformed into lowercase a in the minified script, thus parseSupported is always set to false.

At the moment I don't have time to dig further, but at a first glance this seems to be a problem with the Closure Compiler ADVANCED_OPTIMIZATIONS option.

Please update Jam package

Please republish your Jam package. v3.2.2 seems borked, as it defines the package json, instead of json3:

define("json", (JSON3 = {}));

... resulting in an undefined JSON3. This issue seems to be fixed in at least v3.2.4.

JSON3 Performance

README.md states:
"Informal benchmarks have shown that JSON 3 is slower than Crockford's recursive descent parser and Mike Samuel's json-sans-eval, but approximates the speed of the eval-based JSON 2 parser."

So I decided to write a JSPerf test to compare JSON3's parse method to that of JSON2's and Crockford's non-eval based implementations: http://jsperf.com/crockfords-json-libraries

It seems to be the case that JSON3 is actually about on par with Crockford's recursive descent parser, but significantly slower than his eval parser. Though, it's worth double checking my test setup, as I may have goofed something up when changing code around to avoid collisions between json2 and json3.

Not really an issue, but I thought you might find a more formal benchmark interesting.

ES 6 Compatiblity

We'll want to keep an eye on environments that support ES 6—particularly cases like new Proxy([], {})). This polyfill should never be necessary in an ES 6 environment, but, as we've discovered with Firefox, the feature tests can be too strict.

Opera >= 10.53 `getUTC*` Method Bugs

@Yaffle first noted in es-shims/es5-shim#111 that Date#getUTCMonth is buggy for certain date values (in this case, -3509827334573292) in Opera 11.62 and 12. Researching the matter further, I discovered that getUTC{FullYear, Month, Date, Hours} are also buggy, producing incorrect and/or nonsensical results (please see the aforementioned issue for the results and discussion).

The following test is expected to fail in Opera 10.53 and higher (the failure is not consistent, however, as different results are produced across versions). It should pass in 9.64 and earlier:

this.serializes('"-109252-01-01T10:37:06.708Z"', new Date(-3509827334573292));

I have pinged Mike Taylor on Twitter regarding the regression. Pending further investigation, this issue is on hold.

Native `parse` implementation is buggy in IE 9

27 tests currently fail in IE 9, which uses the native JSON.parse implementation:

Octal Values: 1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 29, 30, 33, 34, 37, 38, 41, 42, 45, 46.

Numeric Literals: 20.

Poor code coverage in environments with spec-compliant native implementations

Istanbul currently reports that JSON 3 has 13.77% coverage. This is actually correct, since the native stringify and parse implementations are used in Node; however, this metric is also not very useful. I've merged d10/json3@a5e43925b7c8889e0d3d34f52d4082c758b58eff to squelch the Travis failures, but it would be wonderful to investigate how other polyfills measure code coverage.

JSON3 obliterates existing polyfills on window.JSON even when loading as an AMD module

JSON3 (3.2.4) wraps itself in a self-executing function so that simply by loading the js file, it will execute. That might be okay if it didn't have side-effects, but it turns out that just by bundling the code in another AMD module, it will execute the self-invoking function in json3 and that executes the has() checks and determines in some cases that the existing parser (e.g. json2) isn't standards compliant and so it will replace the stringify and parse functions with JSON3! Even before loading the module itself!. I think that the only thing that the module should do in a self-invoking function is set up the define() invocation so that on file load, we will have json3 registered as a module to possibly load, but not diddle with window.JSON functions just by parsing the code. That should require actually loading the code in a module context.

I think the define should return a factory that will invoke the logic with side-effects and not invoke that logic on loading (in an AMD context).

Here's what I tweaked locally that illustrates probably a safer pattern:

pull all of the AMD detection logic and definition out into a self-invoking function:

(function() {
      // Detect the `define` function exposed by asynchronous module loaders. The
  // strict `define` check is necessary for compatibility with `r.js`.
  var isLoader = typeof define === "function" && define.amd, JSON3 = !isLoader && typeof exports == "object" && exports;

  if (JSON3 || isLoader) {
    if (typeof JSON == "object" && JSON) {
      // Delegate to the native `stringify` and `parse` implementations in
      // asynchronous module loaders and CommonJS environments.
      if (isLoader) {
        JSON3 = JSON;
      } else {
        JSON3.stringify = JSON.stringify;
        JSON3.parse = JSON.parse;
      }
    } else if (isLoader) {
      JSON3 = this.JSON = {};
    }
  } else {
    // Export for web browsers and JavaScript engines.
    JSON3 = this.JSON || (this.JSON = {});
    json3init();    // call the init code with side-effects here
  }

  // Export for asynchronous module loaders.
  if (isLoader) {
    define(function () {
      json3init();
      return JSON3;
    });
  }
})();

And remove the self-invoking function and instead assign this to a named function that can be called at the right time.
This is not unlike a UMDjs factory pattern https://github.com/umdjs/umd

var json3init = (function() {
...
    // all of the other json3 code goes here
});

It would be cleaner if the code removed the implicit global JSON3 variable diddling and changed to a real factory method that returns an instance instead of initializing an implicit global var. you could then use the return value to assign to window.JSON3 only when warranted and avoid polluting global scope if not desired.

Native `parse` is buggy in Firefox 4.0 and 4.0.1

The following tests fail under Firefox 4.0 and 4.0.1, which uses the native JSON.parse implementation:

Numeric Literals

  • Leading +
  • Trailing decimal point
  • Leading decimal point

Octal Values

  • Octal and negative octal literals: 1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 29, 30, 33, 34, 37, 41, 42, 45, 46

The feature test should be expanded to cover these cases.

Not working in >IE8

I have tried both JSON2 and JSON3, and I can't get it to work. Below is my JSON function, can anyone please tell me what is wrong?

jQuery(document).ready(function() {
(function ($) {
$('select[name="post_type"]').change(function (event) {
$("#location-dropdown").prop("disabled", true);
$('select[name="location"]').html("Loading...");
$.post("", {
action: 'wpse158929_get_terms_for_cpt',
post_type: $(this).val(),
taxonomy: ,
current_selected: $('select[name="location"]').val(),
nonce:
}, function( response ) {
if ( response && !response.error ) {
$('select[name="location"]').html(response.html);
$("#location-dropdown").prop("disabled", false);
}
}, 'json'
);
});
// Remove if you don't want to call change immediately.
$('select[name="post_type"]').change();
})(jQuery);
});

Are there any known browsers that don't work with json3?

Are there any browsers or environments that are known to work with json2 (or others) that don't work with json3?

I note that you list the methods which need to be implemented - Are there known instances which don't have these?

Host object property access may throw

Some environments (e.g. ExtendScript) have host objects that are actually just projections into JavaScript from C++ or whatever. Accessing properties on those objects may throw an error in some cases.

Minified version in npm

Would it be possible to add a minified version to the nodejs release please? I would like to use it for auto-updates in cdnjs.

Make a new tag to reflect the changes

I use angular generator and this uses json3 version 3.3.1, this version uses json3.min.js, and the dev version, fix it to json3.js. To reflect the changes please make a new tag.

Thanks!

JSON3 hangs IE7 with particular json data with long string property values.

I created a jsperf to demonstrate the issue. Even in IE8 the issue is pronounced (allowing a mere 6 ops/second). http://jsperf.com/json-parser-perf-ie-largestringproperties

We experienced an issue where json3 was causing the IE7 browser to literally hang. I've tried running the jsperf in IE7 and it has only hung the browser thus far so there is no data yet. IE8 took a while but it did finish.

Without IE profiler, I can see if I can generate some metrics from dynatrace to identify which specific function(s) or aspects of the functions might be the culprits.

EDIT: Dynatrace shows only one stand-out function and that is the lex() function when processing the string property value itself. It took 4779ms to parse that one string. I'm not sure why sometimes the browser hangs in our real environment (or the jsperf) but it doesn't hang when running the same parse in isolation, other than for the 5 seconds or more it's parsing and the cpu is pegged.

<?xml version="1.0" encoding="utf-8"?><browser_purepath_tree><nodeinfo level="7" function="lex()" arguments="" return="@&lt;div class=&quot;columns columns-aligned ...TRUNCATED for brevity" start_ms="7658.334229629743" total_ms="4778.469051234164" exec_ms="4778.46923828125" exec="38.39862" api="json3, JavaScript" agent="Browser"/></browser_purepath_tree>

`walk` should not use `splice` when removing an array element

walk should use the delete operator when removing elements from arrays, instead of Array#splice.

Expected:

JSON.parse("[1, 2, 3]", function (key, value) {
  if (typeof value == "object" && value) {
    return value;
  }
}).length == 3;

Actual:

JSON.parse("[1, 2, 3]", function (key, value) {
  if (typeof value == "object" && value) {
    return value;
  }
}).length == 0;

Anonymous define

Is it possible to replace define(function () { return A }) with define("json3", function () { return A })? It's wreaking havoc havoc with other requirejs scripts on page

keen/keen-js#112 (comment)

JSON.parse is failing in IE 7 with production and development code

I tired the JSON.parse ( simple example: JSON.parse('{"a":1}') ) in IE7 using the json3 production and development code. It is throwing an exception as "Exception occurred and not caught" but when i try the same using the branch code, it is working correctly.

Development Code: http://cdnjs.cloudflare.com/ajax/libs/json3/3.2.6/json3.js
Production Code: http://cdnjs.cloudflare.com/ajax/libs/json3/3.2.6/json3.min.js

IE7 is throwing the error even when I tried with json3.2.5 also.

Please help.

168 failures in the Adobe ExtendScript engine

Cf. https://github.com/subtleGradient/json3/compare/subtlegradient;extendscript

Started spec `JSON 3 Unit Tests`.
Started test ``parse`: String Literals`.
Assertion: Double-quoted string literal.
Assertion: Empty string literal.
Assertion: String containing an escaped Unicode line separator.
Assertion: String containing an escaped Unicode paragraph separator.
Assertion: String containing an unescaped Unicode surrogate pair.
Assertion: String containing an escaped ASCII control character.
Assertion: String containing an escaped backspace.
Assertion: String containing an escaped form feed.
Assertion: String containing an escaped line feed.
Assertion: String containing an escaped carriage return.
Assertion: String containing an escaped tab.
Assertion: String containing an escaped solidus.
Assertion: String containing an escaped reverse solidus.
Assertion: String containing an escaped double-quote character.
Failure: Single-quoted string literal. Expected: true. Actual: false.
Failure: String containing a hex escape sequence. Expected: true. Actual: false.
Failure: String containing an unescaped CRLF line ending. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: String containing an unescaped ASCII control character. Expected: true. Actual: false.
Failure: done. Expected: 50. Actual: 14.
Finished test ``parse`: String Literals`. 14 assertions, 36 failures.
Started test `ECMAScript 5 Conformance`.
Failure: Valid whitespace characters may not separate two discrete tokens. Expected: true. Actual: false.
Failure: The vertical tab is not a valid whitespace character. Expected: true. Actual: false.
Failure: The form feed is not a valid whitespace character. Expected: true. Actual: false.
Failure: The non-breaking space is not a valid whitespace character. Expected: true. Actual: false.
Failure: The zero-width space is not a valid whitespace character. Expected: true. Actual: false.
Failure: The byte order mark (zero-width non-breaking space) is not a valid whitespace character. Expected: true. Actual: false.
Failure: Other Unicode category `Z` characters are not valid whitespace characters. Expected: true. Actual: false.
Failure: The line (U+2028) and paragraph (U+2029) separators are not valid whitespace characters. Expected: true. Actual: false.
Assertion: Valid whitespace characters may precede and follow all tokens.
Assertion: Leading tab characters should be ignored.
Failure: A tab character may not separate two disparate tokens. Expected: true. Actual: false.
Assertion: Leading carriage returns should be ignored.
Failure: A carriage return may not separate two disparate tokens. Expected: true. Actual: false.
Assertion: Leading line feeds should be ignored.
Failure: A line feed may not separate two disparate tokens. Expected: true. Actual: false.
Assertion: Leading space characters should be ignored.
Failure: A space character may not separate two disparate tokens. Expected: true. Actual: false.
Assertion: Strings must be enclosed in double quotes.
Failure: Single-quoted strings are not permitted. Expected: true. Actual: false.
Failure: Unicode-escaped double quote delimiters are not permitted. Expected: true. Actual: false.
Failure: Strings must terminate with a double quote character. Expected: true. Actual: false.
Assertion: Strings may be empty.
Failure: Unescaped control characters in the range [U+0000, U+0007] are not permitted within strings. Expected: true. Actual: false.
Failure: Unescaped control characters in the range [U+0008, U+000F] are not permitted within strings. Expected: true. Actual: false.
Failure: Unescaped control characters in the range [U+0010, U+0017] are not permitted within strings. Expected: true. Actual: false.
Failure: Unescaped control characters in the range [U+0018, U+001F] are not permitted within strings. Expected: true. Actual: false.
Assertion: Unicode escape sequences are permitted within strings.
Failure: Unicode escape sequences may not comprise fewer than four hexdigits. Expected: true. Actual: false.
Failure: Unicode escape sequences may not contain non-hex characters. Expected: true. Actual: false.
Assertion: Escaped solidus.
Assertion: Escaped reverse solidus.
Assertion: Escaped backspace.
Assertion: Escaped form feed.
Assertion: Escaped line feed.
Assertion: Escaped carriage return.
Assertion: Escaped tab.
Assertion: `JSON.stringify(undefined)` should return `undefined`.
Assertion: The `JSON.stringify` callback function can be called on a top-level `undefined` value.
Assertion: `JSON.stringify` should serialize top-level string primitives.
Assertion: `JSON.stringify` should serialize top-level number primitives.
Assertion: `JSON.stringify` should serialize top-level Boolean primitives.
Assertion: `JSON.stringify` should serialize top-level `null` values.
Assertion: `JSON.stringify` should serialize top-level number objects.
Assertion: `JSON.stringify` should serialize top-level string objects.
Assertion: `JSON.stringify` should serialize top-level Boolean objects.
Assertion: The `JSON.stringify` callback function may return `undefined` when called on a top-level number primitive.
Assertion: The `JSON.stringify` callback function may return `undefined` when called on a top-level object.
Assertion: The `JSON.stringify` callback function may return an array when called on a top-level number primitive.
Assertion: The `JSON.stringify` callback function may return an object literal when called on a top-level number primitive.
Assertion: `JSON.stringify` should return `undefined` when called on a top-level function.
Assertion: The `JSON.stringify` callback function may return a number primitive when called on a top-level function.
Assertion: `JSON.stringify` should ignore `filter` arguments that are not functions or arrays.
Assertion: Optional `width` argument: Number object and primitive width values should produce identical results.
Assertion: Optional `width` argument: String object and primitive width values should produce identical results.
Assertion: Optional `width` argument: The maximum numeric width value should be 10.
Assertion: Optional `width` argument: Numeric values should be converted to integers.
Assertion: Optional `width` argument: Numeric width values between 0 and 1 should be ignored.
Assertion: Optional `width` argument: Zero should be ignored.
Assertion: Optional `width` argument: Negative numeric values should be ignored.
Assertion: Optional `width` argument: Numeric width values in the range [1, 10] should produce identical results to that of string values containing `width` spaces.
Assertion: Optional `width` argument: String width values longer than 10 characters should be truncated.
Assertion: Empty string `width` arguments should be ignored.
Assertion: Boolean primitive `width` arguments should be ignored.
Assertion: `null` `width` arguments should be ignored.
Assertion: Boolean object `width` arguments should be ignored.
Assertion: Object literal `width` arguments should be ignored.
Assertion: An object literal with a custom `toJSON` method nested within an array may return a string primitive for serialization.
Assertion: An object literal with a custom `toJSON` method nested within an array may return a number object for serialization.
Assertion: An object liyeral with a custom `toJSON` method nested within an array may return a Boolean object for serialization.
Assertion: The `JSON.stringify` callback function may return a string object when called on an array.
Assertion: The `JSON.stringify` callback function may return a number object when called on an array.
Assertion: The `JSON.stringify` callback function may return a Boolean object when called on an array.
Failure: An object containing a circular reference should throw a `TypeError`. Expected: true. Actual: false.
Failure: A nested cyclic structure should throw a `TypeError`. Expected: true. Actual: false.
Failure: done. Expected: 74. Actual: 51.
Finished test `ECMAScript 5 Conformance`. 51 assertions, 24 failures.
Started test ``parse`: Object Literals`.
Assertion: Object literal containing one member.
Assertion: Object literal containing multiple members.
Failure: Unquoted identifier used as a property name. Expected: true. Actual: false.
Failure: `false` used as a property name. Expected: true. Actual: false.
Failure: `true` used as a property name. Expected: true. Actual: false.
Failure: `null` used as a property name. Expected: true. Actual: false.
Failure: Single-quoted string used as a property name. Expected: true. Actual: false.
Failure: Number used as a property name. Expected: true. Actual: false.
Failure: Trailing comma in object literal. Expected: true. Actual: false.
Failure: done. Expected: 9. Actual: 2.
Finished test ``parse`: Object Literals`. 2 assertions, 8 failures.
Started test ``parse`: Octal Values`.
Failure: Octal literal. Expected: true. Actual: false.
Failure: Negative octal literal. Expected: true. Actual: false.
Failure: Octal escape sequence in a string. Expected: true. Actual: false.
Failure: Hex escape sequence in a string. Expected: true. Actual: false.
Failure: Octal literal. Expected: true. Actual: false.
Failure: Negative octal literal. Expected: true. Actual: false.
Failure: Octal escape sequence in a string. Expected: true. Actual: false.
Failure: Hex escape sequence in a string. Expected: true. Actual: false.
Failure: Octal literal. Expected: true. Actual: false.
Failure: Negative octal literal. Expected: true. Actual: false.
Failure: Octal escape sequence in a string. Expected: true. Actual: false.
Failure: Hex escape sequence in a string. Expected: true. Actual: false.
Failure: Octal literal. Expected: true. Actual: false.
Failure: Negative octal literal. Expected: true. Actual: false.
Failure: Octal escape sequence in a string. Expected: true. Actual: false.
Failure: Hex escape sequence in a string. Expected: true. Actual: false.
Failure: Octal literal. Expected: true. Actual: false.
Failure: Negative octal literal. Expected: true. Actual: false.
Failure: Octal escape sequence in a string. Expected: true. Actual: false.
Failure: Hex escape sequence in a string. Expected: true. Actual: false.
Failure: Octal literal. Expected: true. Actual: false.
Failure: Negative octal literal. Expected: true. Actual: false.
Failure: Octal escape sequence in a string. Expected: true. Actual: false.
Failure: Hex escape sequence in a string. Expected: true. Actual: false.
Failure: Octal literal. Expected: true. Actual: false.
Failure: Negative octal literal. Expected: true. Actual: false.
Failure: Octal escape sequence in a string. Expected: true. Actual: false.
Failure: Hex escape sequence in a string. Expected: true. Actual: false.
Failure: Octal literal. Expected: true. Actual: false.
Failure: Negative octal literal. Expected: true. Actual: false.
Failure: Octal escape sequence in a string. Expected: true. Actual: false.
Failure: Hex escape sequence in a string. Expected: true. Actual: false.
Failure: Octal literal. Expected: true. Actual: false.
Failure: Negative octal literal. Expected: true. Actual: false.
Failure: Octal escape sequence in a string. Expected: true. Actual: false.
Failure: Hex escape sequence in a string. Expected: true. Actual: false.
Failure: Octal literal. Expected: true. Actual: false.
Failure: Negative octal literal. Expected: true. Actual: false.
Failure: Octal escape sequence in a string. Expected: true. Actual: false.
Failure: Hex escape sequence in a string. Expected: true. Actual: false.
Failure: Octal literal. Expected: true. Actual: false.
Failure: Negative octal literal. Expected: true. Actual: false.
Failure: Octal escape sequence in a string. Expected: true. Actual: false.
Failure: Hex escape sequence in a string. Expected: true. Actual: false.
Failure: Octal literal. Expected: true. Actual: false.
Failure: Negative octal literal. Expected: true. Actual: false.
Failure: Octal escape sequence in a string. Expected: true. Actual: false.
Failure: Hex escape sequence in a string. Expected: true. Actual: false.
Failure: done. Expected: 48. Actual: 0.
Finished test ``parse`: Octal Values`. 0 assertions, 49 failures.
Started test ``parse`: Array Literals`.
Failure: Trailing comma in array literal. Expected: true. Actual: false.
Assertion: Nested arrays.
Assertion: Array containing empty object literal.
Assertion: Mixed array.
Failure: done. Expected: 4. Actual: 3.
Finished test ``parse`: Array Literals`. 3 assertions, 2 failures.
Started test ``parse`: Invalid Expressions`.
Failure: Source string containing a JavaScript expression. Expected: true. Actual: false.
Failure: Source string containing a JavaScript expression. Expected: true. Actual: false.
Failure: Source string containing a JavaScript expression. Expected: true. Actual: false.
Failure: Source string containing a JavaScript expression. Expected: true. Actual: false.
Failure: Source string containing a JavaScript expression. Expected: true. Actual: false.
Failure: Source string containing a JavaScript expression. Expected: true. Actual: false.
Failure: done. Expected: 6. Actual: 0.
Finished test ``parse`: Invalid Expressions`. 0 assertions, 7 failures.
Started test ``stringify` and `parse`: Optional Arguments`.
Assertion: Callback function provided.
Assertion: Object; optional `filter` and `whitespace` arguments.
Failure: List of non-enumerable property names specified as the `filter` argument. Expected: "{\u0022PI\u0022:3.141592653589793}". Actual: "{\u0022PI\u0022:3.14159265358979}".
Assertion: Issue #10: `walk` should not use `splice` when removing an array element.
Failure: done. Expected: 4. Actual: 3.
Finished test ``stringify` and `parse`: Optional Arguments`. 3 assertions, 2 failures.
Started test ``parse`: Whitespace`.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing an invalid Unicode whitespace character. Expected: true. Actual: false.
Failure: Source string containing a vertical tab. Expected: true. Actual: false.
Failure: Source string containing a form feed. Expected: true. Actual: false.
Failure: Source string containing a byte-order mark. Expected: true. Actual: false.
Assertion: Source string containing a CRLF line ending.
Assertion: Source string containing multiple line terminators.
Assertion: Source string containing a tab character.
Assertion: Source string containing a space character.
Failure: done. Expected: 26. Actual: 4.
Finished test ``parse`: Whitespace`. 4 assertions, 23 failures.
Started test ``parse`: Empty Source Strings`.
Failure: Empty JSON source string. Expected: true. Actual: false.
Failure: Source string containing only line terminators. Expected: true. Actual: false.
Failure: Source string containing a single space character. Expected: true. Actual: false.
Failure: Source string containing multiple space characters. Expected: true. Actual: false.
Failure: done. Expected: 4. Actual: 0.
Finished test ``parse`: Empty Source Strings`. 0 assertions, 5 failures.
Started test `Anticipated ECMAScript 6 Additions`.
Finished test `Anticipated ECMAScript 6 Additions`. 0 assertions, 0 failures.
Started test ``stringify``.
Assertion: `null` is represented literally.
Assertion: `Infinity` is serialized as `null`.
Assertion: `NaN` is serialized as `null`.
Assertion: `-Infinity` is serialized as `null`.
Assertion: Boolean primitives are represented literally.
Assertion: Boolean objects are represented literally.
Assertion: All control characters in strings are escaped.
Assertion: Arrays are serialized recursively.
Assertion: `[undefined]` is serialized as `[null]`.
Assertion: Objects are serialized recursively.
Assertion: Nested objects containing identically-named properties should serialize correctly.
Assertion: Objects containing duplicate references should not throw a `TypeError`.
Failure: Objects containing complex circular references should throw a `TypeError`. Expected: true. Actual: false.
Assertion: Sparse arrays should serialize correctly.
Assertion: Dates should be serialized according to the simplified date time string format.
Assertion: The date time string should conform to the format outlined in the spec.
Assertion: The minimum valid date value should serialize correctly.
Assertion: The maximum valid date value should serialize correctly.
Assertion: https://bugs.ecmascript.org/show_bug.cgi?id=119.
Assertion: Millisecond values < 1000 should be serialized correctly.
Assertion: Years prior to 0 should be serialized as extended years.
Assertion: Years after 9999 should be serialized as extended years.
Assertion: Issue #4: Opera > 9.64 should correctly serialize a date with a year of `-109252`.
Assertion: Invalid dates should serialize as `null`.
Assertion: Nested arrays; optional `whitespace` argument.
Assertion: Empty array; optional string `whitespace` argument.
Assertion: Empty object; optional numeric `whitespace` argument.
Assertion: Single-element array; optional numeric `whitespace` argument.
Assertion: Single-member object; optional string `whitespace` argument.
Assertion: Nested objects; optional numeric `whitespace` argument.
Failure: done. Expected: 30. Actual: 29.
Finished test ``stringify``. 29 assertions, 2 failures.
Started test ``parse`: Numeric Literals`.
Assertion: Integer.
Assertion: Negative integer.
Assertion: Float.
Assertion: Negative float.
Assertion: Decimal.
Assertion: Negative decimal.
Assertion: Exponential.
Assertion: Positive exponential.
Assertion: Negative exponential.
Assertion: Decimalized exponential.
Assertion: Case-insensitive exponential delimiter.
Failure: Leading `+`. Expected: true. Actual: false.
Failure: Trailing decimal point. Expected: true. Actual: false.
Failure: Leading decimal point. Expected: true. Actual: false.
Failure: Missing exponent. Expected: true. Actual: false.
Failure: Missing signed exponent. Expected: true. Actual: false.
Failure: Leading `--`. Expected: true. Actual: false.
Failure: Trailing `-+`. Expected: true. Actual: false.
Failure: Hex literal. Expected: true. Actual: false.
Failure: Invalid negative sign. Expected: true. Actual: false.
Failure: done. Expected: 20. Actual: 11.
Finished test ``parse`: Numeric Literals`. 11 assertions, 10 failures.
Finished spec `JSON 3 Unit Tests`. 117 assertions, 168 failures.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.