在windows上执行phantom js时出错.无效的json


Error executing phantom js on windows . Invalid json

我正在使用幻影库将我的高图转换为PDF。

当我执行代码时

$result = json_decode(trim(shell_exec($this->getBinPath() . ' ' . escapeshellarg(json_encode($args)))));

返回错误,表示

unable to parse json

正在运行的命令是

 "C:'www'myproject'vendor'kriansa'h2p'bin/win32/phantomjs.exe" "C:'www'myproject'vendor'kriansa'h2p'bin/converter.js" "{ destination : C:''Windows''TEMP''14b6e6edc209b6e731bdbc79976a9430438409ae.tmp , request :{ uri : C:''Windows''TEMP''127ef8f78c335d9af694a9cef0423541dd17a256.html , method : GET }, orientation : Portrait , format : A3 , zoomFactor :1, allowParseCustomFooter :false, allowParseCustomHeader :false, border : 1cm , header :null, footer :null}"

我应该检查什么?我已经验证了作为参数传递的json。

编辑

我也检查了

"C:'www'cimba_aboutmy360'vendor'kriansa'h2p'bin/win32/phantomjs.exe" "C:'www'cimba_aboutmy360'vendor'kriansa'h2p'bin/converter.js" {"destination":"C:''Windows''TEMP''d4ca24267110d5c234b7a006f1ae5c03da248e88.tmp","request":{"uri":"C:''Windows''TEMP''9b5d4d28689c3bc00afc0831666d6ee39a934b5c.html","method":"GET"},"orientation":"Portrait","format":"A3","zoomFactor":1,"allowParseCustomFooter":false,"allowParseCustomHeader":false,"border":"1cm","header":null,"footer":null}

再次出现相同错误

我使用这个工具来验证JS的JSON,它必须通过JS评估测试。

此JSON解析正确:

{ 
    "destination" : "C:''Windows''TEMP''14b6e6edc209b6e731bdbc79976a9430438409ae.tmp",
    "request":
    { 
        "uri" : "C:''Windows''TEMP''127ef8f78c335d9af694a9cef0423541dd17a256.html",
        "method" : "GET"
    }, 
    "orientation" : "Portrait",
    "format" : "A3",
    "zoomFactor" :1, 
    "allowParseCustomFooter" :false, 
    "allowParseCustomHeader" :false, 
    "border" : "1cm",
    "header" :null, 
    "footer" :null
}

注意它们键(destination等)周围的引号以及非本机类型和字符串周围的引号。您可以将null、boolean、integers和decimals保留为不带引号。

编辑

我认为您还需要在命令调用中用引号包装JSON

"C:'www'cimba_aboutmy360'vendor'kriansa'h2p'bin/win32/phantomjs.exe"  
"C:'www'cimba_aboutmy360'vendor'kriansa'h2p'bin/converter.js"
"{'destination':'C:''Windows''TEMP''d4ca24267110d5c234b7a006f1ae5c03da248e88.tmp','request':{'uri':'C:''Windows''TEMP''9b5d4d28689c3bc00afc0831666d6ee39a934b5c.html','method':'GET'},'orientation':'Portrait','format':'A3','zoomFactor':1,'allowParseCustomFooter':false,'allowParseCustomHeader':false,'border':'1cm','header':null,'footer':null}"