Thanks you very much for replying.
The problem was solved and it is really good that to report it.
Now, it deserializes properly.
BTW, I could not find the TextToStringAdaptor easily but in the com.google.ytb suite as one of the inner classes. So I extracted it as:
package com.google.ytb;
import java.lang.reflect.Type;
import com.google.appengine.api.datastore.Text;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
public class TextToStringAdapter implements JsonSerializer<Text>,
JsonDeserializer<Text>
{
public JsonElement toJson(Text text, Type type, JsonSerializationContext context)
{
return serialize(text, type, context);
}
public Text fromJson(JsonElement json, Type type, JsonDeserializationContext context)
{
return deserialize(json, type, context);
}
@Override
public JsonElement serialize(Text text, Type type, JsonSerializationContext context)
{
return new JsonPrimitive(text.getValue());
}
@Override
public Text deserialize(JsonElement json, Type type, JsonDeserializationContext context)
{
try
{
return new Text(json.getAsString());
}
catch (JsonParseException e)
{
// TODO: This is kind of a hacky way of reporting back a parse
// exception.
return new Text(e.toString());
}
}
}
This reminds me that I actually haven't checked if an error text is in the deserialized Text instead of the proper one, although it seems it is working :-(