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

手动添加UTSJSONObject toJSONObject 示例

上级 73510e62
......@@ -12,7 +12,32 @@ export function testUTSJSONObject() : Result {
expect(UTSJSONObject.keys(obj).length).toEqual(2);
console.log(UTSJSONObject.keys(obj))
})
test('toJSONObject', () => {
// #ifdef APP-ANDROID
let result = {}
result["opt"] = "xxxx"
let subArray = [] as Array<UTSJSONObject>
let subModel = {}
subModel["name"] = "xxx"
subModel["type"] = 0
subArray.push(subModel)
let service = {}
service["name"] = "0xxxb34fb"
service["type"] = 0
//这个数据返回为空对象数组
service["array"] = subArray
result["service"] = service
expect(result.toJSONObject().toJSONString()).toEqual('{"opt":"xxxx","service":{"array":[{"name":"xxx","type":0}],"name":"0xxxb34fb","type":0}}');
// #endif
})
test('assign-notype', () => {
// #ifdef APP-ANDROID
const target = { a: 1, b: 2 };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册