cvh Report post Posted February 23, 2012 Hello, I'm using Google GSON to build my JSON content, which I then use in a Scatter chart. The GSON produces valid JSON (which I have verified by running through the validator at jsonlint.com), but the Scatter chart fails to display correctly - the caption, palette, number prefix, axis names etc. don't show. By tinkering with the JSON I find it all works as intended (i.e. all chart elements display correctly) if I remove a few brackets, which are causing the problem - please see the .png attachment to this thread to see what I mean by unnecessary brackets. My question is - how do I get the JSON into a form recognised by FusionCharts, as having valid JSON seems somehow to be insufficient? (I have also attached the HTML generated so the FusionChart moderators can try and reproduce the problem and the fix). Thank you. 0010010011_2012-02-23_15:37:10.html Share this post Link to post Share on other sites
cvh Report post Posted February 24, 2012 Any ideas, please? Share this post Link to post Share on other sites
Guest Sumedh Report post Posted February 24, 2012 Greetings, GSON service will not provide the valid JSON which is required to a plot chart. You will have to implement your own code, to generate a valid JSON. Hope this helps. Share this post Link to post Share on other sites
cvh Report post Posted February 24, 2012 Thank you for your reply. Does this mean that FusionCharts doesn't adhere to the JSON standard? Or are you saying that GSON doesn't output valid JSON? If the latter then that's surprising, as I have run the JSON generated by GSON through a number of validators and it passes every time. Share this post Link to post Share on other sites
cvh Report post Posted February 24, 2012 (edited) For anyone else stumbling into this issue, I fixed it by this horrible hack (which just feels wrong!): 1. generate your JSON using GSON 2. strip the offending brackets - I used StringUtils from the lang library of the Apache Commons project - see here. 3. The Java code I used was as follows: String generatedJson = StringUtils.replace(generatedJson, "}},{", "},"); NB - line 3 above assumes you are generating compact JSON, i.e. not using the 'pretty printing' constructor of GSON. If you use pretty printing you will need to handle the line breaks between the curly braces. Edited February 24, 2012 by cvh Share this post Link to post Share on other sites
Guest Sumedh Report post Posted February 28, 2012 Hi, I am glad that, you have managed to resolve your issue. And also, thanks a lot for the post. Appreciate your efforts. Happy FusionCharting ! Share this post Link to post Share on other sites