score:6

Accepted answer

I finally solved the problem. I guess there is mis-understanding in the so called "JSON" string. The Javascript export server does not accept any real "JSON" string. A real "JSON" string would have all strings quoted, some thing like

 {
       "value": [1,2,3],
       "name": "jack"
 }

What the export server accepts are actually a piece of Javascript code to create a Javascript object, like:

 {
       value: [1,2,3],
       name: "jack"
 }

This is because the server will use this string as part of the Javascript code in the generated webpage. I wrote a small function to convert JSON string into this format and pass it to the server, it finally works.

var getUnQuotedJsonString = function (str) {
  return str.replace(/"\w+":/g, function(s, key) {
    return s.replace(/"/g, "");
  });
}

score:-1

This is because the Phantoms HTTP server which is started by

phantomjs highcharts-convert.js -host ... -port ...

expects the parameters send in JSON format. Please read, the documentation, parapgraph 'start as a webserver'

Out of curiosity... what typo did you found?

score:-1

I wrote a similar function to solve this for PHP if anyone is looking to remove the quotes from the result of json_encode -

function unQuote($str){
return preg_replace_callback('/"\w+":/',
                        function ($match){
                             return str_replace('"', '', $match[0]);
                         }, 
                         $str );
}

score:0

I got that same error when I tried to send in a JSON string that was longer than what my server hosting the highcharts exporter WAR file would accept. Check your message length parameter in your server. Make sure it is long enough to hold the request sent. Now, since you do not mention what export server you are using (java or PHP) I would imagine you did not actually set up the web front end for the export server and you just have the headless command line export set up (phantomJS + some highcharts js files). To use the exporting server for use in the front end (like when a user clicks on the export buttons on the web page) you also need to set up Java or PHP.


Related Query

More Query from same tag