Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+26 votes

I setup our ProjectDataTest class the exact same way as Professor Stonedahl's and I included the same methods in our ProjectData class for JSON/Gson stuff but I keep getting this error: "com.sun.javafx.jmx.HighlightRegion declares multiple JSON fields named hash".

Has any other group encountered this issue as well? Does anyone have any advice for saving/loading progress with JSON and Gson?

asked in CSC285_Fall2018 by (1 point)

1 Answer

+7 votes
 
Best answer

Yes, another group approached me with this problem.

The likely culprit is that your Video class contains a javafx Rectangle object, which is more of a graphical widget than just a pure data storage object, and apparently GSON can't handle serializing it.

You may want to have a JavaFX Rectangle in order to draw it in your GUI, but inside the Video class you should probably store it as either a javafx.geometry.Rectangle2D object, or perhaps as a java.awt.Rectangle.

answered by (508 points)
selected by
0

http://lovelace.augustana.edu/q2a/index.php/433/we-have-a-problem-about-save&load-on-json

This question is also having a similar issue and most of the groups have it and none of us are sure how to fix it. Is it possible that the Paint thing isn't serializing correctly? Here's the error message:

java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to javafx.graphics@10.0.2/com.sun.prism.paint.Paint

at javafx.graphics/com.sun.javafx.sg.prism.NGCanvas.renderStream(NGCanvas.java:971)
at javafx.graphics/com.sun.javafx.sg.prism.NGCanvas.renderContent(NGCanvas.java:607)
at javafx.graphics/com.sun.javafx.sg.prism.NGNode.renderOpacity(NGNode.java:2357)
at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2060)
at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
at javafx.graphics/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
at javafx.graphics/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
at javafx.graphics/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
at javafx.graphics/com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:479)
at javafx.graphics/com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:321)
at javafx.graphics/com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at javafx.graphics/com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
at java.base/java.lang.Thread.run(Thread.java:844)
...