Skip to content

Commit 2433c48

Browse files
author
Arian
committed
Support Hash in JSON
1 parent 42467d0 commit 2433c48

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Source/Utilities/JSON.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ JSON.encode = JSON.stringify || function(obj){
5151
return '"' + obj.replace(/[\x00-\x1f\\"]/g, escape) + '"';
5252
case 'array':
5353
return '[' + obj.map(JSON.encode).clean() + ']';
54-
case 'object':
54+
case 'object': case 'hash':
5555
var string = [];
56-
for (var key in obj){
57-
var json = JSON.encode(obj[key]);
56+
Object.each(obj, function(value, key){
57+
var json = JSON.encode(value);
5858
if (json) string.push(JSON.encode(key) + ':' + json);
59-
}
59+
});
6060
return '{' + string + '}';
6161
case 'number': case 'boolean': return '' + obj;
6262
case 'null': return 'null';

0 commit comments

Comments
 (0)