1、将Map写入json文件中
Map<String,String> map = getAllSystemFactorIDAndNameMap();
String filePath ="C:/Users/lin/stagingtest/backend-ft/src/test/resources/portfolio/template/";
ObjectMapper mapper = new ObjectMapper();
try {
(new File(filePath), map);
} catch (IOException e) {
();
}
2、将json文件中的数据通过key 取出来使用
public String getValue(String requestKey){
resourceFilePath = "/factor/request_data/";
URL pathAsUrl = (resourceFilePath);
StringBuffer originalFileContent = new StringBuffer();
try{
BufferedReader br = new BufferedReader(new FileReader(()));
String s = null;
while((s = ())!=null) {
(s + "\n");
}
();
}catch(Exception e){
();
}
//add slash '\' for all ' " ' in string: {"a":1, "b":2 } -> {\"a\":1, \"b\":2}
// return ().replace("\"", "\\\"");
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode (());
return (requestKey).asText;
}