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:
Cédric Krier committed 2021-01-11 00:11:25 +01:00
1 parent ef0c5a5a37
commit b291df2381
2 files changed
+6

No files matched your search

+2
View File
@@ -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);
+4
View File
@@ -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),