提交 be721d20 编写于 作者: 杜庆泉's avatar 杜庆泉

JSON 增加部分示例

上级 991eee47
...@@ -47,6 +47,16 @@ export function testJSON() : Result { ...@@ -47,6 +47,16 @@ export function testJSON() : Result {
expect(obj2.getString("object.nestedKey")).toEqual('nestedValue') 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 支持,暂不放开 // 目前仅android 支持,暂不放开
// let obj3 = JSON.parse<User>(json1); // let obj3 = JSON.parse<User>(json1);
// console.log(obj3) // console.log(obj3)
......
...@@ -3,7 +3,6 @@ import { testDate } from './Date.uts' ...@@ -3,7 +3,6 @@ import { testDate } from './Date.uts'
import { testString } from './String.uts' import { testString } from './String.uts'
import { testError } from './Error.uts' import { testError } from './Error.uts'
import { testKeyWord } from './KeyWord.uts' import { testKeyWord } from './KeyWord.uts'
import { testExtapi } from './Extapi.uts'
import { testJSON } from './JSON.uts' import { testJSON } from './JSON.uts'
import { testNumber } from './Number.uts' import { testNumber } from './Number.uts'
import { testMap } from './Map.uts' import { testMap } from './Map.uts'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册