我试图使用序列杰克逊Java中的对象,但是当我试图序列化,它给了我这个错误序列化对象到JSON:无法使用杰克逊
No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer
I tried this post, but it didn't help.
这里是我试图序列化类:
public class Repository {
public String name;
@JsonIgnore // to avoid recursive calls
public ArrayList<UserRole> contributors = new ArrayList<UserRole>();
public User self;
public ArrayList<FileInfo> files;
public RepositoryType repositoryType;
public String path;
}
我还试图创建getter/setter方法对每个领域,但仍然一无所获。
这里是我的序列化方法:
public static String convertObjectToJson(Object object) throws IOException {
ObjectWriter objectWriter = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = objectWriter.writeValueAsString(object); //error on this line
return json;
}
什么是'FileInfo'?你如何期望杰克逊序列化它? –
杰克逊为什么不应该序列化它?当im将对象传递给序列化程序时,files字段为空。 –