FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Socket.IO-node/example/json.js at master · mycoding/Socket.IO-node · GitHub
mycoding
/
Socket.IO-node
Public
forked from
socketio/socket.io
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Socket.IO-node
/
example
/
json.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
18 lines (18 loc) · 1.84 KB
Breadcrumbs
Socket.IO-node
/
example
/
json.js
Copy path
File metadata and controls
18 lines (18 loc) · 1.84 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
if
(
!
this
.
JSON
)
{
JSON
=
function
(
)
{
function
f
(
n
)
{
return
n
<
10
?
'0'
+
n
:
n
;
}
Date
.
prototype
.
toJSON
=
function
(
)
{
return
this
.
getUTCFullYear
(
)
+
'-'
+
f
(
this
.
getUTCMonth
(
)
+
1
)
+
'-'
+
f
(
this
.
getUTCDate
(
)
)
+
'T'
+
f
(
this
.
getUTCHours
(
)
)
+
':'
+
f
(
this
.
getUTCMinutes
(
)
)
+
':'
+
f
(
this
.
getUTCSeconds
(
)
)
+
'Z'
;
}
;
var
m
=
{
'\b'
:
'\\b'
,
'\t'
:
'\\t'
,
'\n'
:
'\\n'
,
'\f'
:
'\\f'
,
'\r'
:
'\\r'
,
'"'
:
'\\"'
,
'\\'
:
'\\\\'
}
;
function
stringify
(
value
,
whitelist
)
{
var
a
,
i
,
k
,
l
,
r
=
/
[
"
\\
\x00
-
\x1f
\x7f
-
\x9f
]
/
g
,
v
;
switch
(
typeof
value
)
{
case
'string'
:
return
r
.
test
(
value
)
?
'"'
+
value
.
replace
(
r
,
function
(
a
)
{
var
c
=
m
[
a
]
;
if
(
c
)
{
return
c
;
}
c
=
a
.
charCodeAt
(
)
;
return
'\\u00'
+
Math
.
floor
(
c
/
16
)
.
toString
(
16
)
+
(
c
%
16
)
.
toString
(
16
)
;
}
)
+
'"'
:
'"'
+
value
+
'"'
;
case
'number'
:
return
isFinite
(
value
)
?
String
(
value
)
:
'null'
;
case
'boolean'
:
case
'null'
:
return
String
(
value
)
;
case
'object'
:
if
(
!
value
)
{
return
'null'
;
}
if
(
typeof
value
.
toJSON
===
'function'
)
{
return
stringify
(
value
.
toJSON
(
)
)
;
}
a
=
[
]
;
if
(
typeof
value
.
length
===
'number'
&&
!
(
value
.
propertyIsEnumerable
(
'length'
)
)
)
{
l
=
value
.
length
;
for
(
i
=
0
;
i
<
l
;
i
+=
1
)
{
a
.
push
(
stringify
(
value
[
i
]
,
whitelist
)
||
'null'
)
;
}
return
'['
+
a
.
join
(
','
)
+
']'
;
}
if
(
whitelist
)
{
l
=
whitelist
.
length
;
for
(
i
=
0
;
i
<
l
;
i
+=
1
)
{
k
=
whitelist
[
i
]
;
if
(
typeof
k
===
'string'
)
{
v
=
stringify
(
value
[
k
]
,
whitelist
)
;
if
(
v
)
{
a
.
push
(
stringify
(
k
)
+
':'
+
v
)
;
}
}
}
}
else
{
for
(
k
in
value
)
{
if
(
typeof
k
===
'string'
)
{
v
=
stringify
(
value
[
k
]
,
whitelist
)
;
if
(
v
)
{
a
.
push
(
stringify
(
k
)
+
':'
+
v
)
;
}
}
}
}
return
'{'
+
a
.
join
(
','
)
+
'}'
;
}
}
return
{
stringify
:
stringify
,
parse
:
function
(
text
,
filter
)
{
var
j
;
function
walk
(
k
,
v
)
{
var
i
,
n
;
if
(
v
&&
typeof
v
===
'object'
)
{
for
(
i
in
v
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
apply
(
v
,
[
i
]
)
)
{
n
=
walk
(
i
,
v
[
i
]
)
;
if
(
n
!==
undefined
)
{
v
[
i
]
=
n
;
}
}
}
}
return
filter
(
k
,
v
)
;
}
if
(
/
^
[
\]
,
:
{
}
\s
]
*
$
/
.
test
(
text
.
replace
(
/
\\
.
/
g
,
'@'
)
.
replace
(
/
"
[
^
"
\\
\n
\r
]
*
"
|
t
r
u
e
|
f
a
l
s
e
|
n
u
l
l
|
-
?
\d
+
(?:
\.
\d
*
)
?
(?:
[
e
E
]
[
+
\-
]
?
\d
+
)
?
/
g
,
']'
)
.
replace
(
/
(?:
^
|
:
|
,
)
(?:
\s
*
\[
)
+
/
g
,
''
)
)
)
{
j
=
eval
(
'('
+
text
+
')'
)
;
return
typeof
filter
===
'function'
?
walk
(
''
,
j
)
:
j
;
}
throw
new
SyntaxError
(
'parseJSON'
)
;
}
}
;
}
(
)
;
}
Back
|
FazBrowse Home
|
New Git URL