MCPcopy
hub / github.com/google/gson / JsonDeserializer

Interface JsonDeserializer

src/main/java/com/google/gson/JsonDeserializer.java:70–88  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

68 * deserializer may be asked to deserialize a specific generic type of the T.
69 */
70public 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}

Callers 8

assertParsedMethod · 0.65
deserializeMethod · 0.65
deserializeMethod · 0.65
deserializeMethod · 0.65
deserializeMethod · 0.65
deserializeMethod · 0.65
deserializeMethod · 0.65

Implementers 15

ExceptionJsonDeserializersrc/test/java/com/google/gson/JsonDese
ExceptionTypeAdaptersrc/test/java/com/google/gson/GsonType
AtomicIntegerTypeAdaptersrc/test/java/com/google/gson/GsonType
MyParameterizedTypeAdaptersrc/test/java/com/google/gson/Paramter
CrazyLongTypeAdaptersrc/test/java/com/google/gson/common/T
NullObjectAndFieldTestsrc/test/java/com/google/gson/function
CustomDeserializerTestsrc/test/java/com/google/gson/function
DataHolderDeserializersrc/test/java/com/google/gson/function
MyEnumTypeAdaptersrc/test/java/com/google/gson/function
CustomTypeAdaptersTestsrc/test/java/com/google/gson/function
FooTypeAdaptersrc/test/java/com/google/gson/function
StringHolderTypeAdaptersrc/test/java/com/google/gson/function

Calls

no outgoing calls

Tested by

no test coverage detected