首页 > 代码库 > json对象传入js方法失败

json对象传入js方法失败

1 var msg:String = {"isBannedUid":"119","isBannedUserId":"112554","isBannedNickName":"test"};2 var obj:Object = new Object();3 var jsons:String = "";4 obj.msg = msg;5 jsons = JSON.stringify(obj);6 ExternalInterface.call("test", jsons);

此时无法成功调用js的test方法,应当改为下面的写法就可以调到了

1 var msg:String = {"isBannedUid":"119","isBannedUserId":"112554","isBannedNickName":"test"};2 var obj:Object = new Object();3 var jsons:String = "";4 var obgMsg:Object = JSON.parse(msg);5 obj.msg = obgMsg;6 jsons = JSON.stringify(obj);7 ExternalInterface.call("test", jsons);