From be721d208e99b287b7971690a9c57a11cd89b5b0 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Wed, 23 Aug 2023 13:10:10 +0800 Subject: [PATCH] =?UTF-8?q?JSON=20=E5=A2=9E=E5=8A=A0=E9=83=A8=E5=88=86?= =?UTF-8?q?=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/JSON.uts | 12 +++++++++++- uni_modules/uts-tests/utssdk/index.uts | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts index 274fd4e..6ff5df7 100644 --- a/uni_modules/uts-tests/utssdk/JSON.uts +++ b/uni_modules/uts-tests/utssdk/JSON.uts @@ -46,7 +46,17 @@ export function testJSON() : Result { }) expect(obj2.getString("object.nestedKey")).toEqual('nestedValue') - + + let json3 = `{"id":"216776999999","name":"小王","grade":1.0,"list":[1,2,3],"address":{"province":"beijing","city":"haidian","streat":"taipingzhuang","other":2},"anyValue":[[null,null]],"obj":{"a":1,"b":false,"c":null},"customClass":{"name":"lisi","age":30},"numList":[1,2,3,null],"list2":[1,2,3,4],"dic":{"1":{"c":[null]}},"dicArr":[{"a":{"c":[null]}},{"b":{"c":1}}]}` + let obj3 = JSON.parse(json3)! as UTSJSONObject; + let obj3Address = obj3.getAny("address")! + console.log(obj3Address) + expect(obj3Address instanceof UTSJSONObject).toEqual(true) + let obj3DicArr = obj3.getArray("dicArr")! + let obj3DicArrFirst = obj3DicArr[0] as UTSJSONObject + let obj3DicArrFirstA = obj3DicArrFirst['a'] + console.log(obj3DicArrFirstA instanceof UTSJSONObject) + expect(obj3DicArrFirstA instanceof UTSJSONObject).toEqual(true) // 目前仅android 支持,暂不放开 // let obj3 = JSON.parse(json1); // console.log(obj3) diff --git a/uni_modules/uts-tests/utssdk/index.uts b/uni_modules/uts-tests/utssdk/index.uts index 9f07ef2..7376eaf 100644 --- a/uni_modules/uts-tests/utssdk/index.uts +++ b/uni_modules/uts-tests/utssdk/index.uts @@ -3,7 +3,6 @@ import { testDate } from './Date.uts' import { testString } from './String.uts' import { testError } from './Error.uts' import { testKeyWord } from './KeyWord.uts' -import { testExtapi } from './Extapi.uts' import { testJSON } from './JSON.uts' import { testNumber } from './Number.uts' import { testMap } from './Map.uts' -- GitLab