Encode Decimal with it primitive value for PYSON
Otherwise the Decimal is duplicated as a generic Object by the preparation. issue9852 review330001002
This commit is contained in:
1 parent
ef0c5a5a37
commit
b291df2381
2 files changed
+6
No files matched your search
@@ -85,6 +85,8 @@
|
||||
value.seconds(),
|
||||
value.milliseconds() * 1000).pyson();
|
||||
}
|
||||
} else if (value instanceof Sao.Decimal) {
|
||||
value = value.valueOf();
|
||||
} else if ((value instanceof Object) &&
|
||||
!(value instanceof Sao.PYSON.PYSON)) {
|
||||
value = jQuery.extend({}, value);
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
QUnit.test('PYSON Encoder', function() {
|
||||
var encoder = new Sao.PYSON.Encoder();
|
||||
var none;
|
||||
var decimal = Sao.Decimal(1.1);
|
||||
var pyson_decimal = 1.1;
|
||||
var date = Sao.Date(2002, 0, 1);
|
||||
var datetime = Sao.DateTime(2002, 0, 1, 12, 30, 0, 0);
|
||||
var pyson_date = new Sao.PYSON.Date(2002, 1, 1).pyson();
|
||||
@@ -63,6 +65,8 @@
|
||||
QUnit.strictEqual(encoder.encode(), 'null', "encode()");
|
||||
QUnit.strictEqual(encoder.encode(none), 'null', "encode(none)");
|
||||
QUnit.strictEqual(encoder.encode(null), 'null', "encode()");
|
||||
QUnit.strictEqual(encoder.encode(decimal),
|
||||
JSON.stringify(pyson_decimal), "encode(decimal)");
|
||||
QUnit.strictEqual(encoder.encode(date),
|
||||
JSON.stringify(pyson_date), "encode(date)");
|
||||
QUnit.strictEqual(encoder.encode(datetime),
|
||||
|
||||
Reference in new issue
Block a user