Fix PYSON and JSON for null value
This commit is contained in:
1 parent
243cbfc6ea
commit
6bacf786a3
3 files changed
+18
-5
No files matched your search
+1
-1
@@ -54,7 +54,7 @@
|
||||
},
|
||||
decode: function(str) {
|
||||
var reviver = function(k, v) {
|
||||
if (typeof v == 'object') {
|
||||
if (typeof v == 'object' && v !== null) {
|
||||
var cls = Sao.PYSON[v.__class__];
|
||||
if (cls) {
|
||||
return cls.eval_(v, this.__context);
|
||||
|
||||
+3
-2
@@ -64,7 +64,7 @@
|
||||
Sao.rpc.convertJSONObject(value[i], i, value);
|
||||
}
|
||||
} else if ((typeof(value) != 'string') &&
|
||||
(typeof(value) != 'number')) {
|
||||
(typeof(value) != 'number') && (value !== null)) {
|
||||
if (value && value.__class__) {
|
||||
switch (value.__class__) {
|
||||
case 'datetime':
|
||||
@@ -101,7 +101,8 @@
|
||||
for (var i = 0, length = value.length; i < length; i++) {
|
||||
Sao.rpc.prepareObject(value[i], i, value);
|
||||
}
|
||||
} else if ((typeof(value) != 'string') && (typeof(value) != 'number')) {
|
||||
} else if ((typeof(value) != 'string') &&
|
||||
(typeof(value) != 'number') && (value !== null)) {
|
||||
if (value instanceof Date) {
|
||||
if (value.getHours() || value.getMinutes() ||
|
||||
value.getSeconds())
|
||||
|
||||
+14
-2
@@ -20,16 +20,28 @@
|
||||
},
|
||||
'datetime': new Date(2012, 11, 29, 19, 59, 10),
|
||||
'date': new Date(2012, 11, 29),
|
||||
'decimal': new Sao.Decimal(1.1)
|
||||
'decimal': new Sao.Decimal(1.1),
|
||||
'null': null
|
||||
};
|
||||
for (var name in tests) {
|
||||
var test = tests[name];
|
||||
var result = Sao.rpc.convertJSONObject(jQuery.parseJSON(
|
||||
JSON.stringify(Sao.rpc.prepareObject(test))));
|
||||
QUnit.ok(test.toString() == result.toString(), 'JSON ' + name);
|
||||
var ok_;
|
||||
if (name == 'null') {
|
||||
ok_ = test == result;
|
||||
} else {
|
||||
ok_ = test.toString() == result.toString();
|
||||
}
|
||||
QUnit.ok(ok_, 'JSON ' + name);
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('PYSON Decoder', function() {
|
||||
var decoder = new Sao.PYSON.Decoder();
|
||||
QUnit.strictEqual(decoder.decode('null'), null, "decode('null')");
|
||||
});
|
||||
|
||||
QUnit.test('PYSON.Eval', function() {
|
||||
var value;
|
||||
value = new Sao.PYSON.Eval('test').pyson();
|
||||
|
||||
Reference in new issue
Block a user