-
Notifications
You must be signed in to change notification settings - Fork 115
Open
Description
from the javadoc: "maxObjectGraphDepth int maximum object graph depth allowed during serialization.Default is 10,000 levels. This prevents excessive recursion from deeply nested object structures."
But an lower depth with many objects cann also trigger this error. E.g. maxObjectGraphDepth 10 and a List with 12 elements triggers the exception. The Object depth is 2 and should not trigger this exception.
WriteOptions writeOptions = new WriteOptionsBuilder().maxObjectGraphDepth(10).build();
List<String> list = IntStream.range(0, 12).mapToObj(i -> "test"+i).collect(Collectors.toList());
System.out.println(JsonIo.toJson(list, writeOptions));
Exception in thread "main" com.cedarsoftware.io.JsonIoException: Object graph too deep (>10 levels). This may indicate a circular reference or excessively nested structure.
at com.cedarsoftware.io.JsonWriter.traceReferences(JsonWriter.java:471)
at com.cedarsoftware.io.JsonWriter.write(JsonWriter.java:412)
at com.cedarsoftware.io.JsonIo.toJson(JsonIo.java:162)
at test.main(test.java:37)
A List with 11 Objects works fine
{"@type":"ArrayList","@items":["test0","test1","test2","test3","test4","test5","test6","test7","test8","test9","test10"]}
Metadata
Metadata
Assignees
Labels
No labels