我有一个以下格式的文件:
TEST1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL= TCP)(Host= test100.xyz.com)(Port= 1521))
(CONNECT_DATA = (SID = TEST1))
)
TEST2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL= TCP)(Host= test101.xyz.com)(Port= 1521))
(CONNECT_DATA = (SID = TEST2))
)
有没有一个我可以用来解析并存储为JSON的库?
答案 0 :(得分:-2)
您可以尝试以下代码-
File file=new File("D:\\tnames.txt");
String str=FileUtils.readFileToString(file);
str = str.replace("(", "{");
str = str.replace(")", "}");
str = str.replace("=", ":");
String jsonString = "{" + str + "}";
System.out.println(jsonString);