Skip to content

Commit 420b0f8

Browse files
committed
Adding value to string instead of the other way around. This way it is always forced to be a string
1 parent 6e6ada9 commit 420b0f8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/jquery.json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
return undefined;
5353
}
5454
if ( type === 'number' || type === 'boolean' ) {
55-
return o + '';
55+
return '' + o;
5656
}
5757
if ( type === 'string') {
5858
return $.quoteString( o );

src/jquery.json.min.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(function($){var escapeable=/["\\\x00-\x1f\x7f-\x9f]/g,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};$.toJSON=function(o){if(typeof JSON==='object'&&JSON.stringify){return JSON.stringify(o);}
33
var type=typeof o;if(o===null){return'null';}
44
if(type==='undefined'){return undefined;}
5-
if(type==='number'||type==='boolean'){return o+'';}
5+
if(type==='number'||type==='boolean'){return''+o;}
66
if(type==='string'){return $.quoteString(o);}
77
if(type==='object'){if(typeof o.toJSON==='function'){return $.toJSON(o.toJSON());}
88
if(o.constructor===Date){var month=o.getUTCMonth()+1,day=o.getUTCDate(),year=o.getUTCFullYear(),hours=o.getUTCHours(),minutes=o.getUTCMinutes(),seconds=o.getUTCSeconds(),milli=o.getUTCMilliseconds();if(month<10){month='0'+month;}

0 commit comments

Comments
 (0)