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:
Deepti M 2022-09-12 13:14:05 -04:00 committed by GitHub
parent 847d7f6638
commit a733150cfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -48,10 +48,12 @@ import java.lang.reflect.Type;
* deserializer:</p> * deserializer:</p>
* *
* <pre> * <pre>
* class IdDeserializer implements JsonDeserializer&lt;Id&gt;() { * class IdDeserializer implements JsonDeserializer&lt;Id&gt; {
* public Id deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) * public Id deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
* throws JsonParseException { * throws JsonParseException {
* return new Id((Class)typeOfT, id.getValue()); * long idValue = json.getAsJsonPrimitive().getAsLong();
* return new Id((Class) typeOfT, idValue);
* }
* } * }
* </pre> * </pre>
* *

View File

@ -48,7 +48,7 @@ import java.lang.reflect.Type;
* serializer:</p> * serializer:</p>
* *
* <pre> * <pre>
* class IdSerializer implements JsonSerializer&lt;Id&gt;() { * class IdSerializer implements JsonSerializer&lt;Id&gt; {
* public JsonElement serialize(Id id, Type typeOfId, JsonSerializationContext context) { * public JsonElement serialize(Id id, Type typeOfId, JsonSerializationContext context) {
* return new JsonPrimitive(id.getValue()); * return new JsonPrimitive(id.getValue());
* } * }