Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 可以序列化 java.nio.file.Path ,但不能反序列化 #1732

Closed
hengyunabc opened this issue Aug 14, 2023 · 3 comments
Closed

[BUG] 可以序列化 java.nio.file.Path ,但不能反序列化 #1732

hengyunabc opened this issue Aug 14, 2023 · 3 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@hengyunabc
Copy link

问题描述

import java.nio.file.Path;
import java.nio.file.Paths;

import com.alibaba.fastjson2.JSON;

public class PathTest {

    private Path path;

    public Path getPath() {
        return path;
    }

    public void setPath(Path path) {
        this.path = path;
    }

    public static void main(String[] args) {
        PathTest test = new PathTest();
        test.setPath(Paths.get("/tmp"));

        String jsonString = JSON.toJSONString(test);

        System.out.println(jsonString);

        PathTest test2 = JSON.parseObject(jsonString, PathTest.class);

    }
}

出错信息:

{"path":"/tmp"}
Exception in thread "main" com.alibaba.fastjson2.JSONException: expect ':', but 125, offset 9, character ", line 1, column 10, fastjson-version 2.0.36 {"path":"/tmp"}
	at com.alibaba.fastjson2.JSONReaderASCII.readFieldNameHashCode(JSONReaderASCII.java:614)
	at com.alibaba.fastjson2.reader.ObjectReaderInterface.readObject(ObjectReaderInterface.java:140)
	at com.alibaba.fastjson2.reader.ORG_1_1_PathTest.readObject(Unknown Source)
	at com.alibaba.fastjson2.JSON.parseObject(JSON.java:726)
	at PathTest.main(PathTest.java:26)

环境信息

        <dependency>
            <groupId>com.alibaba.fastjson2</groupId>
            <artifactId>fastjson2</artifactId>
            <version>2.0.36</version>
        </dependency>
@hengyunabc hengyunabc added the bug Something isn't working label Aug 14, 2023
@wenshao wenshao added this to the 2.0.39 milestone Aug 14, 2023
@wenshao
Copy link
Member

wenshao commented Aug 14, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.39-SNAPSHOT/
问题已修复,请帮忙用2.0.39-SNAPSHOT版本验证,2.0.39版本预计在8月27日前发布

@wenshao wenshao added the fixed label Aug 14, 2023
@hengyunabc
Copy link
Author

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.39-SNAPSHOT/ 问题已修复,请帮忙用2.0.39-SNAPSHOT版本验证,2.0.39版本预计在8月27日前发布

测试ok

@wenshao
Copy link
Member

wenshao commented Aug 15, 2023

@wenshao wenshao closed this as completed Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants