提交 74cca3fc 编写于 作者: lizhongyi_'s avatar lizhongyi_

增加含数组下标keypath 取值测试例

上级 9129a17e
......@@ -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<UTSJSONObject>(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}`;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册