From 675c311f293da5808ab5f3ea199ebe184e43e0dc Mon Sep 17 00:00:00 2001 From: m0_75226990 Date: Sat, 9 Sep 2023 19:31:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/JSON.uts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts index 0de4255..18773e0 100644 --- a/uni_modules/uts-tests/utssdk/JSON.uts +++ b/uni_modules/uts-tests/utssdk/JSON.uts @@ -107,13 +107,13 @@ export function testJSON() : Result { // expect(JSON.parse('null')!).toEqual(null); const json4 = '{"data":[{"a":"1"},{"a":2},[{"b":true},{"b":"test"}],[1, 2, 3]]}'; - const obj4 = JSON.parse(json4)!; - expect(obj4.getString('data[0].a')).toEqual("1") - expect(obj4.getNumber('data[1].a')).toEqual(2) - expect(obj4.getBoolean('data[2][0].b')).toEqual(true) - expect(obj4.getAny('data[1].a')).toEqual(2) - expect(obj4.getJSON('data[2][1]')).toEqual({"b":"test"}) - expect(obj4.getArray('data[3]')).toEqual([1, 2, 3]) + const obj4 = JSON.parseObject(json4); + expect(obj4?.getString('data[0].a')).toEqual("1") + expect(obj4?.getNumber('data[1].a')).toEqual(2) + expect(obj4?.getBoolean('data[2][0].b')).toEqual(true) + expect(obj4?.getAny('data[1].a')).toEqual(2) + expect(obj4?.getJSON('data[2][1]')).toEqual({"b":"test"}) + expect(obj4?.getArray('data[3]')).toEqual([1, 2, 3]) }) test('parseObject', () => { -- GitLab