CasperJs loads json data from a local file

前端 未结 3 1986
忘了有多久
忘了有多久 2021-02-14 00:23

Is there any convenient way to load a local JSON file into a variable with CasperJs?

I saw someone suggest to use

$.getJSON(filename, function() ... 
         


        
3条回答
  •  时光说笑
    2021-02-14 01:13

    Here is a complete sample

    var casper = require('casper').create();
    
    var json = require('test.json');
    require('utils').dump(json);
    casper.echo(json['test']);
    
    casper.exit();
    

提交回复
热议问题