The GUID byte[] doesn’t map cleanly to Java UUID bytes, marc refers to GUID’s byte[] behavior as “crazy endianness”, I believe the Java client is using this implementation to covert a GUID’s bytes into a Java UUID.
But you should be able to easily override serialization/deserialization of GUID data types by just getting the JsonServiceClient to use a custom Gson
instance configured with custom Type serializers, this is the default configuration for JsonServiceClient Gson instance:
public GsonBuilder getGsonBuilder() {
return new GsonBuilder()
.registerTypeAdapter(Date.class, JsonSerializers.getDateSerializer())
.registerTypeAdapter(Date.class, JsonSerializers.getDateDeserializer())
.registerTypeAdapter(TimeSpan.class,JsonSerializer.getTimeSerializer())
.registerTypeAdapter(TimeSpan.class,JsonSerializer.getTimeDeserializer())
.registerTypeAdapter(UUID.class, JsonSerializers.getGuidSerializer())
.registerTypeAdapter(UUID.class, JsonSerializers.getGuidDeserializer());
}
public Gson getGson() {
if (gson == null) {
gson = getGsonBuilder().create();
}
return gson;
}
Which you could change by registering your own Gson instance, e.g:
Gson customGson = new GsonBuilder()
.registerTypeAdapter(Date.class, JsonSerializers.getDateSerializer())
.registerTypeAdapter(Date.class, JsonSerializers.getDateDeserializer())
.registerTypeAdapter(TimeSpan.class,JsonSerializer.getTimeSpanSerializer())
.registerTypeAdapter(TimeSpan.class,JsonSerializer.getTimeSpanDeserializer())
.registerTypeAdapter(UUID.class, Custom.getGuidSerializer())
.registerTypeAdapter(UUID.class, Custom.getGuidDeserializer())
.create();
And initialize the Service Client to use it, i.e:
client.setGson(customGson);
Although if you are overriding it, I’d be interested into knowing what you’re using instead.