Android 输入JSONSTRINGRAY的JSON异常

Android 输入JSONSTRINGRAY的JSON异常,android,json,regex,replaceall,Android,Json,Regex,Replaceall,下面是我的JSON ["[0288144111, Please check File Values:==>For input string: "N/A", 20180201]","[4403244111, Upload Not Received, 20180201]","[4246244111, Upload Not Received, 20180201]","[7097244111, Upload Not Received, 20180201]","[9917244111, Upload

下面是我的JSON

["[0288144111, Please check File Values:==>For input string: "N/A", 20180201]","[4403244111, Upload Not Received, 20180201]","[4246244111, Upload Not Received, 20180201]","[7097244111, Upload Not Received, 20180201]","[9917244111, Upload Not Received, 20180201]"]
我使用的是
replaceAll(“[\\\\/:*\?\=”,”)
。由于“NA”中的引号,我仍然收到
JSONException
。如何确保只替换NA周围的引号,而不是整个输入字符串中的引号

编辑

响应:

{"tag":"fetchupdDetailStatus","status":true,"uploadDetails":"[\"[0288144111, Please check File Values:==>For input string: \\\"#N\\\/A\\\", 20180201]\",\"[4403244111, Upload Not Received, 20180201]\",\"[4246244111, Upload Not Received, 20180201]\",\"[7097244111, Upload Not Received, 20180201]\",\"[9917244111, Upload Not Received, 20180201]\"]"}
JSONObject jObj = new JSONObject(response);
if (jObj != null) {
 System.out.println("RESPONSE1===>" + jObj.getString("uploadDetails"));
 String uploadDetails = jObj.getString("uploadDetails");
 String jsonFormattedString = uploadDetails.replaceAll("\\\\", "").replaceAll("[\\\\/:*#?<>|=]", ""); 
 System.out.println("Formatted String getFurtherDetails ==>"+jsonFormattedString);
 jsonArrayUD = new JSONArray(jsonFormattedString);  //getting org.json.JSONException: Unterminated array at character 58
}
RESPONSE1===>["[0288144111, Please check File Values:==>For input string: \"#N\/A\", 20180201]","[4403244111, Upload Not Received, 20180201]","[4246244111, Upload Not Received, 20180201]","[7097244111, Upload Not Received, 20180201]","[9917244111, Upload Not Received, 20180201]"]
Formatted String getFurtherDetails ==>["[0288144111, Please check File ValuesFor input string "NA", 20180201]","[4403244111, Upload Not Received, 20180201]","[4246244111, Upload Not Received, 20180201]","[7097244111, Upload Not Received, 20180201]","[9917244111, Upload Not Received, 20180201]"]
代码:

{"tag":"fetchupdDetailStatus","status":true,"uploadDetails":"[\"[0288144111, Please check File Values:==>For input string: \\\"#N\\\/A\\\", 20180201]\",\"[4403244111, Upload Not Received, 20180201]\",\"[4246244111, Upload Not Received, 20180201]\",\"[7097244111, Upload Not Received, 20180201]\",\"[9917244111, Upload Not Received, 20180201]\"]"}
JSONObject jObj = new JSONObject(response);
if (jObj != null) {
 System.out.println("RESPONSE1===>" + jObj.getString("uploadDetails"));
 String uploadDetails = jObj.getString("uploadDetails");
 String jsonFormattedString = uploadDetails.replaceAll("\\\\", "").replaceAll("[\\\\/:*#?<>|=]", ""); 
 System.out.println("Formatted String getFurtherDetails ==>"+jsonFormattedString);
 jsonArrayUD = new JSONArray(jsonFormattedString);  //getting org.json.JSONException: Unterminated array at character 58
}
RESPONSE1===>["[0288144111, Please check File Values:==>For input string: \"#N\/A\", 20180201]","[4403244111, Upload Not Received, 20180201]","[4246244111, Upload Not Received, 20180201]","[7097244111, Upload Not Received, 20180201]","[9917244111, Upload Not Received, 20180201]"]
Formatted String getFurtherDetails ==>["[0288144111, Please check File ValuesFor input string "NA", 20180201]","[4403244111, Upload Not Received, 20180201]","[4246244111, Upload Not Received, 20180201]","[7097244111, Upload Not Received, 20180201]","[9917244111, Upload Not Received, 20180201]"]

你的问题肯定来自这样一个事实,即双引号从一开始就没有逃过。根据文档,您应该使用:

引用

字符串引号(字符串数据)

将数据编码为JSON字符串。这适用于报价和任何必要的报价 字符转义

参数
数据
字符串
:要编码的字符串。Null将被解释为空字符串


这不是一个有效的json。@SripadRaj这是一个有效的json,但由于数据中的引号,这将变得无效。另外,请尝试…JSONObject JSONObject=new JSONObject(jsonFormattedString);但仍然得到相同的例外..请检查编辑的问题