如何在没有转义序列的JSON对象中写入文件路径列表

时间:2018-09-26 10:59:44

标签: java json regex

由于我是处理json对象并向其写入数据的新手,因此我在将下面提到的文件路径列表添加到json对象时会遇到问题,在json对象上在控制台上打印它时会在其中添加转义符'\'。

     Eg: List of files:
        c://absbd/jdojo/kppl/sample.csv
     c://absbd/jdojo/kppl/sample1.csv
     c://absbd/jdojo/kppl/sample2.csv
     c://absbd/jdojo/kppl/sample3.csv

    Putting this list to json object: 
    JSONObject obj = new JSONObject();
    obj.put("listOfProcessedFiles", abovelist obj);

    I am getting output while doing System.out.println(obj.toString()); as mentiond below:

 c:\/\/absbd\/jdojo\/kppl/sample.csv
 c:\/\/absbd\/jdojo\/kppl\/sample1.csv
  c:\/\/absbd\/jdojo\/kppl\/sample2.csv
  c:\/\/absbd\/jdojo\/kppl\/sample3.csv

I want the o/p as :

    c://absbd/jdojo/kppl/sample.csv
     c://absbd/jdojo/kppl/sample1.csv
     c://absbd/jdojo/kppl/sample2.csv
     c://absbd/jdojo/kppl/sample3.csv

请帮助。

0 个答案:

没有答案