Skip to content

Commit 4a65499

Browse files
committed
JSON2 library was updated to version of June 12, 2017
1 parent 1c46aae commit 4a65499

File tree

3 files changed

+63
-37
lines changed

3 files changed

+63
-37
lines changed

NuGet/MsieJavaScriptEngine.nuspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1313
<description>This library is a .NET wrapper for working with the JavaScript engines of Internet Explorer and Edge (JsRT versions of Chakra, ActiveScript version of Chakra and Classic JavaScript Engine). Project was based on the code of SassAndCoffee.JavaScript (http://github.com/paulcbetts/SassAndCoffee), Chakra Sample Hosts (http://github.com/panopticoncentral/chakra-host) and jsrt-dotnet (http://github.com/robpaveza/jsrt-dotnet).</description>
1414
<summary>This library is a .NET wrapper for working with the JavaScript engines of Internet Explorer and Edge (JsRT versions of Chakra, ActiveScript version of Chakra and Classic JavaScript Engine).</summary>
15-
<releaseNotes>Improved performance of debugging in ActiveScript modes.</releaseNotes>
15+
<releaseNotes>1. Improved performance of debugging in ActiveScript modes;
16+
2. JSON2 library was updated to version of June 12, 2017.</releaseNotes>
1617
<copyright>Copyright (c) 2012-2018 Andrey Taritsyn - http://www.taritsyn.ru</copyright>
1718
<language>en-US</language>
1819
<tags>JavaScript ECMAScript MSIE IE Edge Chakra</tags>

NuGet/readme.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
=============
2222
RELEASE NOTES
2323
=============
24-
Improved performance of debugging in ActiveScript modes.
24+
1. Improved performance of debugging in ActiveScript modes;
25+
2. JSON2 library was updated to version of June 12, 2017.
2526

2627
============
2728
PROJECT SITE

src/MsieJavaScriptEngine/Resources/json2.js

Lines changed: 59 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// json2.js
2-
// 2016-10-28
2+
// 2017-06-12
33
// Public Domain.
44
// NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
5-
// See http://www.JSON.org/js.html
6-
// This code should be minified before deployment.
7-
// See http://javascript.crockford.com/jsmin.html
85

96
// USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
107
// NOT CONTROL.
@@ -113,25 +110,31 @@
113110
// a =
114111
// /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
115112
// if (a) {
116-
// return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
117-
// +a[5], +a[6]));
113+
// return new Date(Date.UTC(
114+
// +a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6]
115+
// ));
118116
// }
117+
// return value;
119118
// }
120-
// return value;
121119
// });
122120

123-
// myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
124-
// var d;
125-
// if (typeof value === "string" &&
126-
// value.slice(0, 5) === "Date(" &&
127-
// value.slice(-1) === ")") {
128-
// d = new Date(value.slice(5, -1));
129-
// if (d) {
130-
// return d;
121+
// myData = JSON.parse(
122+
// "[\"Date(09/09/2001)\"]",
123+
// function (key, value) {
124+
// var d;
125+
// if (
126+
// typeof value === "string"
127+
// && value.slice(0, 5) === "Date("
128+
// && value.slice(-1) === ")"
129+
// ) {
130+
// d = new Date(value.slice(5, -1));
131+
// if (d) {
132+
// return d;
133+
// }
131134
// }
135+
// return value;
132136
// }
133-
// return value;
134-
// });
137+
// );
135138

136139
// This is a reference implementation. You are free to copy, modify, or
137140
// redistribute.
@@ -167,7 +170,7 @@ if (typeof JSON !== "object") {
167170

168171
function f(n) {
169172
// Format integers to have at least two digits.
170-
return n < 10
173+
return (n < 10)
171174
? "0" + n
172175
: n;
173176
}
@@ -181,12 +184,20 @@ if (typeof JSON !== "object") {
181184
Date.prototype.toJSON = function () {
182185

183186
return isFinite(this.valueOf())
184-
? this.getUTCFullYear() + "-" +
185-
f(this.getUTCMonth() + 1) + "-" +
186-
f(this.getUTCDate()) + "T" +
187-
f(this.getUTCHours()) + ":" +
188-
f(this.getUTCMinutes()) + ":" +
189-
f(this.getUTCSeconds()) + "Z"
187+
? (
188+
this.getUTCFullYear()
189+
+ "-"
190+
+ f(this.getUTCMonth() + 1)
191+
+ "-"
192+
+ f(this.getUTCDate())
193+
+ "T"
194+
+ f(this.getUTCHours())
195+
+ ":"
196+
+ f(this.getUTCMinutes())
197+
+ ":"
198+
+ f(this.getUTCSeconds())
199+
+ "Z"
200+
)
190201
: null;
191202
};
192203

@@ -234,8 +245,11 @@ if (typeof JSON !== "object") {
234245

235246
// If the value has a toJSON method, call it to obtain a replacement value.
236247

237-
if (value && typeof value === "object" &&
238-
typeof value.toJSON === "function") {
248+
if (
249+
value
250+
&& typeof value === "object"
251+
&& typeof value.toJSON === "function"
252+
) {
239253
value = value.toJSON(key);
240254
}
241255

@@ -256,7 +270,7 @@ if (typeof JSON !== "object") {
256270

257271
// JSON numbers must be finite. Encode non-finite numbers as null.
258272

259-
return isFinite(value)
273+
return (isFinite(value))
260274
? String(value)
261275
: "null";
262276

@@ -304,7 +318,14 @@ if (typeof JSON !== "object") {
304318
v = partial.length === 0
305319
? "[]"
306320
: gap
307-
? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]"
321+
? (
322+
"[\n"
323+
+ gap
324+
+ partial.join(",\n" + gap)
325+
+ "\n"
326+
+ mind
327+
+ "]"
328+
)
308329
: "[" + partial.join(",") + "]";
309330
gap = mind;
310331
return v;
@@ -320,7 +341,7 @@ if (typeof JSON !== "object") {
320341
v = str(k, value);
321342
if (v) {
322343
partial.push(quote(k) + (
323-
gap
344+
(gap)
324345
? ": "
325346
: ":"
326347
) + v);
@@ -336,7 +357,7 @@ if (typeof JSON !== "object") {
336357
v = str(k, value);
337358
if (v) {
338359
partial.push(quote(k) + (
339-
gap
360+
(gap)
340361
? ": "
341362
: ":"
342363
) + v);
@@ -400,9 +421,10 @@ if (typeof JSON !== "object") {
400421
// Otherwise, throw an error.
401422

402423
rep = replacer;
403-
if (replacer && typeof replacer !== "function" &&
404-
(typeof replacer !== "object" ||
405-
typeof replacer.length !== "number")) {
424+
if (replacer && typeof replacer !== "function" && (
425+
typeof replacer !== "object"
426+
|| typeof replacer.length !== "number"
427+
)) {
406428
throw new Error("JSON.stringify");
407429
}
408430

@@ -456,8 +478,10 @@ if (typeof JSON !== "object") {
456478
rx_dangerous.lastIndex = 0;
457479
if (rx_dangerous.test(text)) {
458480
text = text.replace(rx_dangerous, function (a) {
459-
return "\\u" +
460-
("0000" + a.charCodeAt(0).toString(16)).slice(-4);
481+
return (
482+
"\\u"
483+
+ ("0000" + a.charCodeAt(0).toString(16)).slice(-4)
484+
);
461485
});
462486
}
463487

0 commit comments

Comments
 (0)