adessoSE / wicked-charts

Beautiful and interactive javascript charts for Java-based web applications.
Apache License 2.0
91 stars 48 forks source link

Not valid JSON #24

Closed thombergs closed 8 years ago

thombergs commented 10 years ago

Reported by evgen.kulikoff, Dec 5, 2013 Try to parse JSON below produced by wicked-charts JsonRenderer class: $.parseJSON(json);

"{
  "chart" : {
    "animation" : false,
    "height" : 200,
    "type" : "column",
    "plotShadow" : false,
    "reflow" : false,
    "width" : 500
  },
  "series" : [ {
    "name" : "Charter p.d. (1st)",
    "data" : [ 4200.0, 4200.0 ]
  }, {
    "name" : "Charter p.d. (Plan)",
    "data" : [ 1000.0, 2000.0, 3000.0, 4000.0, 5000.0, 5000.0, 6000.0, 7000.0, 8000.0, 8000.0 ]
  } ],
  "xAxis" : [ {
    "categories" : [ "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020" ],
    "labels" : {
      "align" : "center",
      "style" : { font: 'normal 11px Arial, sans-serif' }
    },
    "plotBands" : [ {
      "color" : "#f0f1f3"
    } ],
    "tickmarkPlacement" : "on"
  } ],
  "yAxis" : [ {
    "labels" : {
      "align" : "right",
      "style" : { font: 'normal 11px Arial, sans-serif' }
    }
  } ],
  "credits" : {
    "enabled" : false
  },
  "plotOptions" : {
    "column" : {
      "animation" : true
    }
  },
  "creditOptions" : {
    "enabled" : false
  }
}"

Expected result: JSON successfull parsed to JS Object. Actual result: The exception thrown: "Uncaught SyntaxError: Unexpected token f"

Also if I try to validate this JSON at http://jsonlint.com/ the validation fails.

Wicked-charts version: 1.5.0

thombergs commented 10 years ago

1 evgen.kulikoff

Switching to quotes in the line 41 in CssStyleSerializer leads to correct JSON parsing:

cssStyleBuilder.append(" \"" + property.getKey() + "\": \"" + property.getValue() + "\",");