forked from extern/egroupware
Add fallback handling using typeof when input.constructor fails
This commit is contained in:
parent
8b74af09c5
commit
4a3c3cf659
@ -111,6 +111,27 @@ function egw_json_encode(input)
|
||||
return '{' + buf.join(',') + '}';
|
||||
|
||||
default:
|
||||
switch(typeof input)
|
||||
{
|
||||
case 'array':
|
||||
var buf = [];
|
||||
for (var k in input)
|
||||
{
|
||||
//Filter non numeric entries
|
||||
if (!isNaN(k))
|
||||
buf.push(egw_json_encode(input[k]));
|
||||
}
|
||||
return '[' + buf.join(',') + ']';
|
||||
|
||||
case 'object':
|
||||
var buf = [];
|
||||
for (var k in input)
|
||||
{
|
||||
buf.push(_egw_json_encode_simple(k) + ':' + egw_json_encode(input[k]));
|
||||
}
|
||||
return '{' + buf.join(',') + '}';
|
||||
|
||||
}
|
||||
return 'null';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user