I'm running a project that requires
- inter-communication between different programming languages (mostly java, c++).
- could serialize/deserialize into both binary format and json format.
- IDL to generate class code for different languages
Thrift matches these criteria perfectly, although we don't need its RPC functions. We will be sending/receiving the serialized thrift data via MQ. Serializing the object is very straight forward. However, when it comes to deserializing, we cannot do something like this:
byte[] data = recv();
Object object = TDeserializer.deserialize(data);
if (object instanceof TypeA) {
TypeA a = (TypeA) object;
} else if (object instanceof TypeB) {
TypeB b = (TypeB) object;
}
It seems we have to tell thrift exactly which struct it needs to deserialize into like:
byte[] data = recv();
TypeA a;
TDeserializer.deserialize(a, data);
Just wondering if there's a way to deserialize raw data into thrift object without knowing its exact type.
Thanks!!