-
Hello, The class is called "PoiLayer" and embedded in a SmartLayerTile I serialize the SmartLayerTile anbd the PoiLayer to Json and to byte arrays. // SmartTile incl the PoiLayer //PoiLayer only Inspecting the results shows a JSON for the SmartLayerTile, where the PoiLayer is embedded as an byte array. Looking at the result of the JSON for the PoiLayer shows correct results. The problems begin when deserializing the bytes from the first JSON. the reader will always reach an out of bounds error or tell me that the value is too big for varsize. So I tried serializing it to an byte array and reading it back in, same errors. I tried deserializing from bytes, from file, and by calling the constructor, always similar errors.
This is the specification of a Poi object (dev acc is free): https://developer.nds.live/schema/poi/2024.03/poi The error occurs for this variable: /**Id of a Poi category.*/ which is embedded in this array: /** List of categories to which the POI belongs. */ I tried setting it with this special varsizetype but it gives the same result as This makes no sense. it can serialize it but not deserialize it. Sounds like a clear bug to me. Also bytes written to file are different than bytes written to RAM. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
Hello Yesyoor, To be honest, I don't understand what exactly is the problem.
This sounds to be ok, since in the PoiLayer within the SmartLayerTile is stored using the Then I got totally lost in what you are trying further.
Here you are just creating an
Please try to make a minimal non-working example, you can try our interactive zserio compiler (unfortunately supports only python runtime, but you can provide the Java code as an attachment within this discussion). Serialization and deserialization of
Data data = new Data();
data.setArray(new int[] {1, 200, 1000});
final byte[] bytes = SerializeUtil.serializeToBytes(data);
Data readData = SerializeUtil.deserializeFromBytes(Data.class, bytes);
System.out.println(data.getArray().length);
System.out.println(readData.getArray().length);
|
Beta Was this translation helpful? Give feedback.
-
@Mi-La Thank you for having taken a look at it already. I feared since it is NDS related and this is about Zserio, that I wouldn't find much support here :) But your explanation about the ext data helped a little already. This is the exception when it tries to deserialize the PoiLayer (with the simple = new int[ ]{0} implementation) : Exception in thread "main" zserio.runtime.ZserioError: SerializeUtil: java.lang.reflect.InvocationTargetException |
Beta Was this translation helpful? Give feedback.
-
@Yesyoor However, regarding the Zserio version I'm not aware of any problems with Zserio 2.12 or 2.13, but you should be always able to use the latest release, currently new 2.14. From a brief look at your quite complex sample, it seems to me that you are trying to deserizalize the JSON files?! This cannot work. It should be possible to read it using You just cannot freely mix JSON a binary formats. Zserio is designed to work only with the binary format - either using JSON was added for debugging purposes and can be used via
|
Beta Was this translation helpful? Give feedback.
-
What about the line 114 in src/act/Main.java:
Here the poiLayerFile is clearly JSON. On lines 104-107:
If you are able to provide really minimalistic (not NDS releated, because it is not public) sample which will demonstrate your problem, I can try to further help you. But in case of NDS please ask the NDS Support. |
Beta Was this translation helpful? Give feedback.
Ah .. I was finally able to debug your project somehow. I have probably found the source of your problem.
It seems to be caused partially by your wrong data and partially by our weak safety checks, which should clearly catch you immediately during serialization!
Poi
defines position with hardcodedcoordShift=0
(see the schemaPosition2D(0)
), but you set it to5
inMain.java
on line162
(methodgeneratePoiMessageList
).Normally we check the parameters to meet the schema restrictions, but it seems that the check is missing in case of packed arrays :-(. Thus now when you try to serialize the
Poi
, it writes the position with number of bits depending on the shift value5
.But when it tries to …