-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for serializing and deserializing java.nio.path
- Loading branch information
1 parent
3ad49b2
commit 7980412
Showing
4 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/org/eclipse/yasson/internal/serializer/PathTypeDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2020 IBM and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
package org.eclipse.yasson.internal.serializer; | ||
|
||
import java.lang.reflect.Type; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import org.eclipse.yasson.internal.Unmarshaller; | ||
import org.eclipse.yasson.internal.model.customization.Customization; | ||
|
||
public class PathTypeDeserializer extends AbstractValueTypeDeserializer<Path> { | ||
public PathTypeDeserializer(Customization customization) { | ||
super(Path.class, customization); | ||
} | ||
|
||
@Override | ||
protected Path deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) { | ||
return Paths.get(jsonValue); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/org/eclipse/yasson/internal/serializer/PathTypeSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2020 IBM and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
package org.eclipse.yasson.internal.serializer; | ||
|
||
import java.nio.file.Path; | ||
|
||
import jakarta.json.stream.JsonGenerator; | ||
|
||
import org.eclipse.yasson.internal.Marshaller; | ||
import org.eclipse.yasson.internal.model.customization.Customization; | ||
|
||
public class PathTypeSerializer extends AbstractValueTypeSerializer<Path> { | ||
public PathTypeSerializer(Customization customization) { | ||
super(customization); | ||
} | ||
|
||
@Override | ||
protected void serialize(Path obj, JsonGenerator generator, Marshaller marshaller) { | ||
generator.write(obj.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters