<dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-toml</artifactId> <version>2.11.2</version> </dependency> import com.fasterxml.jackson.dataformat.toml.TomlMapper; TomlMapper mapper = new TomlMapper(); try { File tomlFile = new File("path/to/file.toml"); Map<String, Object> tomlData = mapper.readValue(tomlFile, new TypeReference<Map<String, Object>>() {}); } catch (IOException e) { e.printStackTrace(); } import com.fasterxml.jackson.dataformat.toml.TomlMapper; TomlMapper mapper = new TomlMapper(); Map<String, Object> tomlData = new HashMap<>(); tomlData.put("key1", "value1"); tomlData.put("key2", 2); try { String tomlString = mapper.writeValueAsString(tomlData); System.out.println(tomlString); } catch (JsonProcessingException e) { e.printStackTrace(); }


上一篇:
下一篇:
切换中文