Re-indented Json processing to 3 spaces issue #39

This commit is contained in:
law39 2020-05-01 13:07:00 +01:00
parent b17a689341
commit b0a3b95d70

View file

@ -12,34 +12,34 @@ import java.util.LinkedList;
public class JsonProcessing { public class JsonProcessing {
public LinkedList<DictionaryEntry> readInJson(File file) { public LinkedList<DictionaryEntry> readInJson(File file) {
LinkedList<DictionaryEntry> returnVal = new LinkedList<>(); LinkedList<DictionaryEntry> returnVal = new LinkedList<>();
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
try { try {
returnVal.addAll(Arrays.asList(objectMapper.readValue(file, DictionaryEntry[].class))); returnVal.addAll(Arrays.asList(objectMapper.readValue(file, DictionaryEntry[].class)));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return returnVal; return returnVal;
} }
public void writeOutJson(String directoryAndFile, LinkedList<DictionaryEntry> words) { public void writeOutJson(String directoryAndFile, LinkedList<DictionaryEntry> words) {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
String JsonString = ""; String JsonString = "";
try { try {
JsonString = objectMapper.writeValueAsString(words); JsonString = objectMapper.writeValueAsString(words);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
Files.writeString(Paths.get(directoryAndFile), JsonString); Files.writeString(Paths.get(directoryAndFile), JsonString);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }