Skip to content

Commit

Permalink
Fix: GSON Adapters for File + MetadataMap
Browse files Browse the repository at this point in the history
  • Loading branch information
SonarSonic committed Jan 10, 2025
1 parent f7a1991 commit 9d8f0c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
public class JsonAdapterFile implements JsonSerializer<File>, JsonDeserializer<File> {

@Override
public File deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
return new File(json.getAsString());
public JsonElement serialize(File src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(src.getPath());
}

@Override
public JsonElement serialize(File src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(src.getAbsolutePath());
public File deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
return new File(json.getAsString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public MetadataMap deserialize(JsonElement json, Type typeOfT, JsonDeserializati
if(metadataType == null) {
continue;
}
Object value = context.deserialize(metadata.get("key"), metadataType.type);
Object value = context.deserialize(metadata.get(key), metadataType.type);
if(value == null){
continue;
}
Expand Down

0 comments on commit 9d8f0c6

Please sign in to comment.