封装了个函数,通过路径访问对象
export function getValueByPath(obj:any, path:string):any|null {
if(obj instanceof UTSJSONObject){
//为啥不能这样写 const current= obj.getAny(path) as any;
//会报错error: java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Any
//不写却没事
const current= obj.getAny(path);
// 返回最终的值
return current;
}
return null;
}
0 个回复