json文件转换list
public static String[] parseJson(String[] json) {
StringBuilder sb = new StringBuilder();
try {
BufferedReader bufferedReader = Files.newBufferedReader(Paths.get(json[0]), StandardCharsets.UTF_8);
String line;
while ((line = bufferedReader.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
Map<String, Object> objectMap = JSON.parseObject(sb.toString(), new TypeReference<Map<String, Object>>() {
});
List<String> list = new ArrayList<>();
for (Map.Entry<String, Object> map : objectMap.entrySet()) {
list.add("-" + map.getKey());
list.add(map.getValue().toString());
}
return list.toArray(new String[0]);
}