Permalink
Browse files

Quote functions in output

  • Loading branch information...
1 parent a4ea56d commit a1b6fbf101332761f6e8dcfd591cbf89e0f03bde @kriszyp committed Jul 30, 2010
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/json-ext.js
View
@@ -193,13 +193,15 @@ exports.stringify = ({}).toSource ?
// What happens next depends on the value's type.
switch (typeof value) {
- case 'string':
- return quote(value);
-
case 'function':
if(nativeConstructors[value.name] === value){
return value.name;
}
+ value = value.toString();
+
+ case 'string':
+ return quote(value);
+
case 'number':
case 'boolean':
case 'undefined':

0 comments on commit a1b6fbf

Please sign in to comment.