当前位置:网站首页>Auto. JS learning note 10: instantiate a custom object and use json The stringify() method causes an error (resolved)
Auto. JS learning note 10: instantiate a custom object and use json The stringify() method causes an error (resolved)
2022-06-12 09:54:00 【PYB3】
Declare that I use autojs yes 4.1.1 edition
JSON.stringify() Use results in autojs The software directly crashes and exits .
Error reporting core local code
var sendInfoObj = { // object
areaCode : "John", // Area parameters
evaInfos : {}, // Expired and expiring information
days : 1, // Expiration days
curGroupName : "", // Current group
groupSize : 0, // Number of groups
size : 0, // Total number
timerState : false, // Timing transmission switch
timingTime : "9:00" // Time to send
};
function toString2(){
log(" The object data is :\n"+JSON.stringify(sendInfoObj));
}
function send_wx_info(evaInfos) {
var thread2 = threads.start(function(){
// Group-sent message
var i = 0;
var Timer = thread2.setInterval(function(){
sleep(600);
var content = '';
if(i==0){
content = '* Release time :'+myUtils.formatDate() +"*\n";
}
if(i < sendInfoObj.size){
setText(content);
text(" send out ").click();
}else{
toString2();
/* End the process */
// back();
clearInterval( Timer );
thread2.interrupt();
exeNextGroup();
// sleep(2666);
// exit();
}
i++;
}, 1600);
});
}
toString2() The call results in an error and related error messages
The sub thread calls with an error
workbench.desktop.main.js:71 [Extension Host] 10:13:44.865/E: Thread[main (Spawn-1),5]: Wrapped java.lang.IllegalArgumentException: class android.content.res.ColorStateList declares multiple JSON fields named mChangingConfigurations (file:///android_asset/modules/__json2__.js#234)Wrapped java.lang.IllegalArgumentException: class android.content.res.ColorStateList declares multiple JSON fields named mChangingConfigurations at str (file:///android_asset/modules/__json2__.js:234:0) at str (file:///android_asset/modules/__json2__.js:338:0) at toString2 ([remote]AutoWeiXinNews.js:132:0) at [remote]AutoWeiXinNews.js:496:0
The main thread calls with an error
JavaException: java.lang.IllegalArgumentException: class android.content.res.ColorStateList declares multiple JSON fields named mChangingConfigurations
Analyze the cause of the error and resolve
Through multiple joint commissioning , Detailed investigation , Confirm that it is an object attribute assignment ui Control return value
UI Local layout code
<input id = "qunNameIt" singleLine = 'true' text=" Wechat robot group , Robot group chat 2" hint=" Enter the group name or user name "></input>
<input id = "areaCodeIt" singleLine = "true" hint=" for example : Zigong City " text='510300- Zigong City '></input>
<input id = "countIt" digit="1234567890" singleLine = "true" text = "3" hint=" Enter the number of days overdue " ></input>
<input id = "endTxt" text = ""></input> The wrong assignment is as follows :(myTrim The function is self defined. Don't worry about it )
sendInfoObj.days = myUtils.myTrim(ui.countIt.getText().toString());
sendInfoObj.areaCode = myUtils.myTrim(ui.areaCodeIt.getText().toString());
sendInfoObj.endHint = ui.endTxt.getText().toString();The correct assignment method is as follows :
sendInfoObj["days"] = myUtils.myTrim(ui.countIt.getText().toString());
sendInfoObj["areaCode"] = myUtils.myTrim(ui.areaCodeIt.getText().toString());
sendInfoObj['endHint'] = ui.endTxt.getText().toString();ui Incorrect assignment results in an error :
sendInfoObj['endHint'] = ui.endTxt.getText(); Remember to join toString()
That's right : sendInfoObj['endHint'] = ui.endTxt.getText().toString();
summary
When the assignment is wrong , The error log related to assignment but not related to assignment is other error ( This is the biggest , It's hard to confirm the problem ).
ui Layout to use sendInfoObj["days"] = myUtils.myTrim(ui.countIt.getText().toString()); To make the correct assignment .
Other values can Directly to “=” Number to assign values , for example :
var json = res.body.string();// Interface obtained json data
var objj = JSON.parse(json); // Turn to object
sendInfoObj.evaInfos = JSON.parse(objj); // Turn to an accessible object and assign a value At present, the situation and solution I see are just like this , There are big guys who can leave messages .
边栏推荐
- CEPH performance optimization and enhancement
- 简单介绍线程和进程区别
- SAP Hana error message sys_ XSA authentication failed SQLSTATE - 28000
- Enumerate all USB device codes
- Value investment
- Auto.js学习笔记9:脚本引擎使用,启动指定路径脚本文件和关闭等基础方法
- Golandidea 2020.01 cracked version
- Common omissions in software test reports, give yourself a wake-up call
- 枚举所有USB设备代码
- The onbindviewholder of recyclerview is called twice at the same time
猜你喜欢

Li Yang, a scientific and technological innovator and CIO of the world's top 500 group: the success of digital transformation depends on people. Decision makers should always focus on "firewood"

Example interview -- dongyuhang: harvest love in the club

High quality and good books help guide apes and recommend "good summer books" with the four major publishers

7-13 地下迷宫探索(邻接表)

Web3.0与数字时尚,该如何落地?

Create simple windowing programs using Visual Studio 2017

Introduction to on-line circuit simulation and open source electronic hardware design

True north reading notes

Auto.js调试:使用雷电模拟器的网络模式进行调试

ThreadLocal
随机推荐
SAP HANA 错误消息 SYS_XSA authentication failed SQLSTATE - 28000
【云原生】具体指什么呢---此文和大伙儿分享答案
GNU EFI development environment settings
Reading notes of the fifth cultivation
The onbindviewholder of recyclerview is called twice at the same time
Implementation of hotspot synchronized
MySQL optimized slow log query
哈希表的线性探测法代码实现
榜样访谈——董宇航:在俱乐部中收获爱情
六月集训(第12天) —— 链表
markdown_ Picture side by side scheme
7-5 哲哲打游戏
存储研发工程师招聘
MySQL-MVCC
IV Transforming regular expressions into finite state automata: DFA minimization
There is always a negative line (upper shadow line) that will stop the advance of many armies, and there is always a positive line (lower shadow line) that will stop the rampant bombing of the air for
《保护我们的数字遗产:DNA数据存储》白皮书发布
Common omissions in software test reports, give yourself a wake-up call
价值投资.
Auto.js学习笔记8:常用且重要的一些API