Below is my 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]"]
I am using replaceAll("[\\\\/:*#?<>|=]", "")
. I am still getting JSONException
due to quotes in "NA". How can I make sure I just replace quotes around NA and not in the whole input string.
Edit
response:
{"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]\"]"}
Code:
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
}
O/P:
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]"]