本文介绍了CasperJs从本地文件加载json数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有使用CasperJs将本地JSON文件加载到变量中的便捷方法?
Is there any convenient way to load a local JSON file into a variable with CasperJs?
我看到有人建议使用
$.getJSON(filename, function() ...
推荐答案
我有以下内容在CasperJS 1.1-beta1和PhantomJS 1.9.1上工作
I have the following working on CasperJS 1.1-beta1 and PhantomJS 1.9.1
test.json
test.json
{
"test": "hello"
}
test .js
var json = require('test.json');
require('utils').dump(json);
casper.echo(json.test); // "hello"
这篇关于CasperJs从本地文件加载json数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!