updated JsonDeserializer example (#2192)
* fixed json deserializer example * correcting the json * updated per review * updated per review * updated per review
This commit is contained in:
parent
847d7f6638
commit
a733150cfa
@ -48,11 +48,13 @@ import java.lang.reflect.Type;
|
||||
* deserializer:</p>
|
||||
*
|
||||
* <pre>
|
||||
* class IdDeserializer implements JsonDeserializer<Id>() {
|
||||
* class IdDeserializer implements JsonDeserializer<Id> {
|
||||
* public Id deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||
* throws JsonParseException {
|
||||
* return new Id((Class)typeOfT, id.getValue());
|
||||
* long idValue = json.getAsJsonPrimitive().getAsLong();
|
||||
* return new Id((Class) typeOfT, idValue);
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>You will also need to register {@code IdDeserializer} with Gson as follows:</p>
|
||||
|
@ -48,7 +48,7 @@ import java.lang.reflect.Type;
|
||||
* serializer:</p>
|
||||
*
|
||||
* <pre>
|
||||
* class IdSerializer implements JsonSerializer<Id>() {
|
||||
* class IdSerializer implements JsonSerializer<Id> {
|
||||
* public JsonElement serialize(Id id, Type typeOfId, JsonSerializationContext context) {
|
||||
* return new JsonPrimitive(id.getValue());
|
||||
* }
|
||||
|
Loading…
Reference in New Issue
Block a user