寻找一个关于如何Map<String, Object>
在Java或Scala中读取/ 写入镶木地板文件的简明示例?
这是预期的结构,com.fasterxml.jackson.databind.ObjectMapper
在Java中用作序列化器(即使用镶木地板寻找等效物):
public static Map<String, Object> read(InputStream inputStream) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readValue(inputStream, new TypeReference<Map<String, Object>>() {
});
}
public static void write(OutputStream outputStream, Map<String, Object> map) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.writeValue(outputStream, map);
}
Run Code Online (Sandbox Code Playgroud)