Interface representing a custom deserializer for Json. You should write a custom deserializer, if you are not happy with the default deserialization done by Gson. You will also need to register this deserializer through GsonBuilder#registerTypeAdapter(Type, Object). Let us look at
| 68 | * deserializer may be asked to deserialize a specific generic type of the T. |
| 69 | */ |
| 70 | public interface JsonDeserializer<T> { |
| 71 | |
| 72 | /** |
| 73 | * Gson invokes this call-back method during deserialization when it encounters a field of the |
| 74 | * specified type. |
| 75 | * <p>In the implementation of this call-back method, you should consider invoking |
| 76 | * {@link JsonDeserializationContext#deserialize(JsonElement, Type)} method to create objects |
| 77 | * for any non-trivial field of the returned object. However, you should never invoke it on the |
| 78 | * the same type passing {@code json} since that will cause an infinite loop (Gson will call your |
| 79 | * call-back method again). |
| 80 | * |
| 81 | * @param json The Json data being deserialized |
| 82 | * @param typeOfT The type of the Object to deserialize to |
| 83 | * @return a deserialized object of the specified type typeOfT which is a subclass of {@code T} |
| 84 | * @throws JsonParseException if json is not in the expected format of {@code typeofT} |
| 85 | */ |
| 86 | public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) |
| 87 | throws JsonParseException; |
| 88 | } |
no outgoing calls
no test coverage detected