当我试图写出一条路径时,杰克逊为什么会给我一个错误?

时间:2017-05-11 07:01:18

标签: java json jackson

我的示例代码:

private void saveData() {
    ObjectMapper mapper = new ObjectMapper();
    try {
        mapper.writeValue( new File ( "test.json" ), Paths.get( "/home/joshua/") );
    } catch ( IOException e ) {
        System.out.println ( "Unable to write json" );
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

错误: com.fasterxml.jackson.databind.JsonMappingException: Direct self-reference leading to cycle (through reference chain: sun.nio.fs.UnixPath["parent"]->sun.nio.fs.UnixPath["parent"]->sun.nio.fs.UnixPath["root"])

当我试图写出一条路径时,杰克逊为什么会破门?

0 个答案:

没有答案