22 lines
547 B
Java
22 lines
547 B
Java
package tc.oc.api.serialization;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Paths;
|
|
|
|
import com.google.gson.TypeAdapter;
|
|
import com.google.gson.stream.JsonReader;
|
|
import com.google.gson.stream.JsonWriter;
|
|
|
|
public class PathTypeAdapter extends TypeAdapter<Path> {
|
|
@Override
|
|
public void write(JsonWriter out, Path value) throws IOException {
|
|
out.value(value.toString());
|
|
}
|
|
|
|
@Override
|
|
public Path read(JsonReader in) throws IOException {
|
|
return Paths.get(in.nextString());
|
|
}
|
|
}
|