代码:
try {//E:\iwater\src\main\resources\config\custom\area-data.js
FileReader fr = new FileReader("E:/iwater/src/main/resources/config/custom/area-data.js");
BufferedReader br = new BufferedReader(fr);
StringBuilder sb = new StringBuilder();
String line = null;
while (null != (line = br.readLine())){
sb.append(line);
}
if (br != null) br.close();
String jsonData = sb.substring(sb.indexOf("{"), sb.lastIndexOf("}")+1);
jsonData = jsonData.replaceAll(" ", "");
jsonData = jsonData.replaceAll("'","\"");
System.out.println(jsonData);
//String preJsonData = jsonData.substring(jsonData.indexOf("86"), jsonData.lastIndexOf("110000")-1);
//System.out.println(preJsonData);
String sufJsonData = jsonData.substring(jsonData.lastIndexOf("110000"), jsonData.lastIndexOf("}"));
sufJsonData = "{" + sufJsonData + "}";
System.out.println(sufJsonData);
System.out.println(sufJsonData);
NutMap map = Json.fromJson(NutMap.class, sufJsonData);
System.out.println(map.size());
} catch (Exception e) {
e.printStackTrace();
}
错误行:
NutMap map = Json.fromJson(NutMap.class, sufJsonData);
错误信息:
org.nutz.json.JsonException: Unexpect EOF
at org.nutz.json.impl.JsonTokenScan.nextChar(JsonCompileImplV2.java:363)
at org.nutz.json.impl.JsonTokenScan.skipComment(JsonCompileImplV2.java:140)
at org.nutz.json.impl.JsonTokenScan._nextToken(JsonCompileImplV2.java:85)
at org.nutz.json.impl.JsonTokenScan.nextToken(JsonCompileImplV2.java:132)
at org.nutz.json.impl.JsonTokenScan.readMap(JsonCompileImplV2.java:175)
at org.nutz.json.impl.JsonTokenScan.read(JsonCompileImplV2.java:343)
at org.nutz.json.impl.JsonCompileImplV2.parse(JsonCompileImplV2.java:26)
at org.nutz.json.Json.fromJson(Json.java:42)
at org.nutz.json.Json.parse(Json.java:77)
at org.nutz.json.Json.fromJson(Json.java:58)
at org.nutz.json.Json.fromJson(Json.java:163)
at cn.nutzwk.copy_area.CopyAreaTest.main(CopyAreaTest.java:43)
请问怎么解决