Skip to content

Commit 66cf5b3

Browse files
committed
Change post #116 to potentially change serialization of java.nio.file.Path
1 parent 2ebaaf1 commit 66cf5b3

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/JSONWriter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,8 @@ protected String dateToString(Date v) {
789789
* @since 2.17
790790
*/
791791
protected String pathToString(Path value) {
792-
return value.toUri().toString();
792+
// return value.toUri().toString();
793+
return value.toString();
793794
}
794795

795796
/*

jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/SimpleValueReader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ protected Path _readPath(JsonParser p) throws IOException {
278278
}
279279
String v = p.getValueAsString();
280280
try {
281-
return Paths.get(new URI(v));
281+
// return Paths.get(new URI(v));
282+
return Paths.get(new File(v).toURI());
282283
} catch (Exception e) {
283284
throw new JSONObjectException("Failed to bind `java.nio.file.Path` from value '"+v+"'");
284285
}

jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/WriteSimpleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ public void testKnownSimpleTypeFile() throws Exception
127127
public void testKnownSimpleTypePath() throws Exception
128128
{
129129
Path p = Paths.get(new URI("file:///foo/bar.txt"));
130-
assertEquals(q("file:///foo/bar.txt"), JSON.std.asString(p));
130+
assertEquals(q("/foo/bar.txt"), JSON.std.asString(p));
131131

132-
assertEquals(a2q("{'path':'file:///foo/bar.txt'}"), JSON.std.asString(new PathWrapper(p)));
132+
assertEquals(a2q("{'path':'/foo/bar.txt'}"), JSON.std.asString(new PathWrapper(p)));
133133
}
134134

135135
public void testSimpleEnumTypes() throws Exception

0 commit comments

Comments
 (0)