From b867420c905c47a99ed18a6e168910c019a7d47f Mon Sep 17 00:00:00 2001 From: duqingquan Date: Mon, 30 Sep 2024 11:32:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0UTSJSONObject.toJSONString=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/UTSJSONObject.uts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts index 4b41a23..fa75416 100644 --- a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts +++ b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts @@ -93,6 +93,21 @@ export function testUTSJSONObject() : Result { expect(data5!.toJSONString()).toEqual('{"data4":{"data":{"num":1,"num2":2.369,"str":"test"},"name":"张三"}}') + class TestData6 implements IJsonStringify{ + toJSON():any|null{ + return JSON.parse("22") + } + } + let testData6 = TestData6() + let data6 = { + data:testData6, + array:[1,"22",false], + name:"data6" + } + + expect(data6!.toJSONString()).toEqual('{"data":22.0,"array":[1,"22",false],"name":"data6"}') + console.log(data6.toJSONString()) + // #endif }) -- GitLab