Hi,
I would like to serialize and deserialize data exchanged through DDS with JSON. I found in a document from Gerardo Pardo that let me hope it is easily feasible (http://www.omg.org/news/meetings/GOV-WS/pr/rte-pres/DDS_WebEnabled_RTEW09.pdf).
After generating the Java class from the IDL description, I succeeds in serializing it into JSON format. The deserialization seems more difficult, perhaps due to the use of sequences and embedded substructures.
Do you have examples of Java code to do such a deserialization?
Thanks in advance.
Hi,
The types generated by rtiddsgen are standard java classes, so it can be easily serialized/serialized using any third party library that does that. One good example is Google Gson library. This library provides JSON serializers/deserializers to Java objects that can be easily incorporated in your code.
Imagine you have this idl definition:
Here it is a snippet of how it can be serialized/deserialize using Google Gson:
The output for this program will be:
Note that might be necessary to build your custom serializer/deserializers for certain data types or complex structures.
Let me know if you have further questions,
- Javier