猿问

如何从文本解析多个JSON,急求大佬帮忙~~

写数据的时候使用的ObjectMapper.writerWithDefaultPrettyPrinter().writeValue(); 优化json输出。。但是我是将多个优化的json输出到同一个文本中,文本文件中的json结果为:

{
  "sourceTitle" : "aaaa,bbbb,cccc,dddd,eeee,ffff",
  "targetTitle" : "aaaa,bbbb,cccc,dddd,eeee,ffff"
}
{
  "errorType" : "DIFFERENT_STATUS",
  "sourceRecords" : [ "1111,2222,3333,4444,5555" ],
  "targetRecords" : [ "1111,2222,3333,4444,5555" ]
}
{
  "errorType" : "DIFFERENT_AMOUNT",
  "sourceRecords" : [ "1111,2222,3333,4444,5555" ],
  "targetRecords" : [ "1111,2222,3333,4444,5555" ]
}

对应的JavaBean

/** title */
    static class Title {
        public String sourceTitle;
        public String targetTitle;
    }
    static class Error {
        public String errorType;
        public String[] sourceRecords;
        public String[] targetRecords;
    }

  使用ObjectMapper.readValue(file, clazz); 只能读取一部分json其他的读取不到。。请问我现在要如何从文本文件中读取json,并将它们写入到对应的javaBean中?。我该如何办呐?  哪位大佬指一条明路啊

慕工程0266419
浏览 678回答 0
0回答

慕斯4360584

BSAVMHRSJGKWKIEIQBARVDYRCTJWJOKSDVIZNUCGKRIPMINROSDFVWNMYDJAXCUHFJDYSIZHRCZXQNGXLCHEFISCJMQEFWWKEELEPXIGOPIRGWPADRYUHOBYPKNHZGTKOMMNLOZDAUPKNIWMXZECDYZVPDTCVADRFPSDKEYHESJHBHLIIFGUHMBCWMHERCWNUFPVPKHKZLSUQNJULWFQOHTALRUGIRRGXUFAHEIPVQEDRJGCURPJMVCNWNOMAATKRYSDKBKJURUOPNROSWEXXEJBAULGBSLFCNPTRVCNMNGMRVSMHFUHPSUCTXULDBZZDXFCDXYBNKGGYZKLIWHTQGPUESOTAUDNNGOQXASWEICYLBZGACDVAVHJWSEXWQWTRFDSWKHOPNMQUNJNKSNOMLJUNCGHFAVZRCGNVLJXNHPJUVLQAHIGICBRPKMQXURHOZGKMJVSQHODSFLFZXUXO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