Unable to parse JSON string with highcharts export

2019-07-06 07:30发布

问题:

What i did:

  • Download the latest phantomjs (1.9.2, windows)
  • Download the latest sources of highcharts-convert.js from github (note: download the whole directory)
  • Start phantomjs with convert script in server mode:

bin\phantomjs.exe --debug=yes js\highcharts-convert.js -host 127.0.0.1 -port 3003

  • Use CURL to send example json to phantomjs server:

curl -H "Content-Type: application/json" -X POST -d '{"infile":"{xAxis: {categories: [\"Jan\", \"Feb\", \"Mar\"]},series: [{data: [29.9, 71.5, 106.4]}]}"}' 127.0.0.1:3003

What I got:

Failed rendering: SyntaxError: Unable to parse JSON string

Note: This is running fine on the command line:

bin\phantomjs js\highcharts-convert.js -infile options.json -outfile chart.svg