jdereg / json-io

Convert Java to JSON. Convert JSON to Java. Pretty print JSON. Java JSON serializer. Deep copy Java object graphs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Revisiting issue 17

williamclocksin opened this issue · comments

Although the issue seems to be fixed and closed, it is still happening in the application. Here are the first few lines of the JSON I get when I try to serialise a document. Notice in line 3 (depending where your page wraps), where the hangers field is supposed to serialise to a list where the first element is a calliope.TextBox. Its area field gets serialised to an object called "@id":37, which ought not be there, and is over 400 lines long (not shown). My custom serialiser correctly serialises the area (as shown in the report for Issue 17) but only when the TextBox is not in an ArrayList. When it is in an ArrayList as shown here, it doesn't do the custom serialisation.

{"@id":352,"@type":"calliope.Document","pages":[{"@id":1,"@type":"calliope.Page","document":{"@ref":352},"format":"PGCENTRE","alignment":"NONE","topsys":0,"botsys":0,"topEdge":0.0,"bottomEdge":0.0,"fillheight":698.0,"num":0,"type":"PAGE","bb":null,"hangers":[{"@type":"calliope.TextBox","subtype":7,"xoff":282.0,"yoff":290.0,"area":{"@id":37,"highlightTextFill":{"@type":"org.fxmisc.richtext.CustomStyleableProperty","bean":{"@ref":37},"name":"highlightTextFill","cssMetaData":{"@type":"org.fxmisc.richtext

PS: I downloaded and installed the Master code before testing this.

Yes, fair request. It may take some time to prepare a small test case, as this is in a program of some 56,000 lines.

Understood. One difference between the tests and my code is that my classes are all subclasses two or more deep, where your People and Pet are base classes (not extensions of any class other than Object). I wonder if that matters.

Very embarrassing: My testing code to test your fix was faulty. Your fix indeed was correct. In one of my tests of your fix, I had written
arg.put(JsonWriter.CUSTOM_WRITER_MAP, Serialising.getCustomWriters());
after the
json = JsonWriter.objectToJson(obj, arg)
and not before. This is why I seemed to get the problem in one of my tests, but not all. Mea culpa. Issue closed.