相关疑难解决方法(0)

使用jackson创建json对象

如何使用jackson创建类似于下面示例的json数组.

我尝试使用ObjectMapper,但这似乎不正确.

      try (DirectoryStream<Path> ds = Files.newDirectoryStream(path)) {
            for (Path file : ds) {
                System.out.println("name:"+file.getFileName()+
                        "\n"+
                        "mime:"+Files.probeContentType(file)+
                "\n"+
                "locked:"+!Files.isWritable(file));
            }
        } catch (IOException e) {
            System.err.println(e);
        }
Run Code Online (Sandbox Code Playgroud)

最终我将制作一个具有以下值的json.

 * - (int)    size    file size in b. required
 * - (int)    ts      file modification time in unix time. required
 * - (string) mime    mimetype. required for folders, others - optionally
 * - (bool)   read    read permissions. required
 * - (bool)   write   write permissions. required
 * - (bool)   locked  is object locked. …
Run Code Online (Sandbox Code Playgroud)

java json hashmap jackson

31
推荐指数
4
解决办法
8万
查看次数

标签 统计

hashmap ×1

jackson ×1

java ×1

json ×1