我需要加载JSON文件并在循环中迭代它。这是json
test.json:
SELECT ( case
when SUBSTR(fieldname, 5,1) = upper (SUBSTR(fieldname, 5,1)) then lower (SUBSTR(fieldname, 5,1))
when SUBSTR(fieldname, 5,1) = lower (SUBSTR(fieldname, 5,1)) then upper (SUBSTR(fieldname, 5,1))
else SUBSTR(fieldname, 5,1) ) 5char
FROM YourTable
Casper脚本:
[
["AA", "1112223333"],
["AM", "2223334444"],
["BF", "3334445555"],
["CP", "4445556666"],
["JB", "5556667777"],
["TC", "6667778888"],
["TT", "7778889999"]
]
最终我看到它像文件一样加载为数组。然后我将遍历变量并使用脚本中的初始和电话号码。
答案 0 :(得分:1)
您可以尝试"每个"功能(here)
这是一个示例代码。
var casper = require('casper').create({
logLevel: 'debug'
});
var json = require('test.json');
casper.start().each(json, function(self, item, index) {
this.echo(item[1]);
// Also you can use index to filter the items inside array.
}).run();