From 651ed78d7be1c97d416466ed6f3eaad021b8b895 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Thu, 21 Sep 2023 17:32:39 +0800 Subject: [PATCH] =?UTF-8?q?json=20stringify=20=E7=A4=BA=E4=BE=8B=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/JSON.uts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts index 031669d..61259af 100644 --- a/uni_modules/uts-tests/utssdk/JSON.uts +++ b/uni_modules/uts-tests/utssdk/JSON.uts @@ -1,4 +1,4 @@ -import { describe, test, expect, Result } from './tests.uts' +import { describe, test, expect,expectNumber, Result } from './tests.uts' @@ -254,6 +254,15 @@ export function testJSON() : Result { expect(JSON.stringify(obj22)).toEqual('{"data":[{"$m":"test","$p":["type"]}]}') + type A = { + inserted: number + } + const str = '{"inserted": 2}' + const obj33 = JSON.parse(str)! + console.log('-------------------------'); + console.log(obj33.inserted); + expectNumber(obj33.inserted).toEqualDouble(2.0) + expect(JSON.stringify(obj33.inserted)).toEqual("2") }) -- GitLab