diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts index 2690a94f988e80784a388585b47c36082064dfbd..0de425515b6b47e57d1e4b23915480f09c10724e 100644 --- a/uni_modules/uts-tests/utssdk/JSON.uts +++ b/uni_modules/uts-tests/utssdk/JSON.uts @@ -104,7 +104,17 @@ export function testJSON() : Result { // TODO 不支持boolean、string,js端需抹平 // expect(JSON.parse('true')!).toEqual(true); // expect(JSON.parse('"foo"')!).toEqual("foo"); - // expect(JSON.parse('null')!).toEqual(null); + // 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]) + }) test('parseObject', () => { const json = `{"result":true, "count":42}`;