如何显示整个错误消息?我知道它的HTML响应而不是JSON ..
如何查看<br >
的其余内容以查看错误消息是什么?
01-04 15:59:00.710: E/JSON Parser(13508): Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
01-04 15:59:00.720: E/AndroidRuntime(13508): FATAL EXCEPTION: AsyncTask #3
01-04 15:59:00.720: E/AndroidRuntime(13508): Process: com.example.coa, PID: 13508
01-04 15:59:00.720: E/AndroidRuntime(13508): java.lang.RuntimeException: An error occurred while executing doInBackground()
01-04 15:59:00.720: E/AndroidRuntime(13508): at android.os.AsyncTask$3.done(AsyncTask.java:309)
01-04 15:59:00.720: E/AndroidRuntime(13508): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
01-04 15:59:00.720: E/AndroidRuntime(13508): at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
01-04 15:59:00.720: E/AndroidRuntime(13508): at java.util.concurrent.FutureTask.run(FutureTask.java:242)
01-04 15:59:00.720: E/AndroidRuntime(13508): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
01-04 15:59:00.720: E/AndroidRuntime(13508): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
01-04 15:59:00.720: E/AndroidRuntime(13508): at java.lang.Thread.run(Thread.java:818)
01-04 15:59:00.720: E/AndroidRuntime(13508): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.json.JSONObject.toString()' on a null object reference
01-04 15:59:00.720: E/AndroidRuntime(13508): at com.example.coa.OfflineSV$SyncScans.doInBackground(OfflineSV.java:419)
01-04 15:59:00.720: E/AndroidRuntime(13508): at com.example.coa.OfflineSV$SyncScans.doInBackground(OfflineSV.java:1)
01-04 15:59:00.720: E/AndroidRuntime(13508): at android.os.AsyncTask$2.call(AsyncTask.java:295)
01-04 15:59:00.720: E/AndroidRuntime(13508): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-04 15:59:00.720: E/AndroidRuntime(13508): ... 3 more
答案 0 :(得分:1)
只需@IBOutlet weak var startButton: UIButton! {
didSet {
startButton.backgroundColor = ECConstants.GenericColors.buttonOrange
startButton.setTitleColor(UIColor.white, for: .normal)
startButton.addGradient(withColors: [UIColor.white.withAlphaComponent(0.3).cgColor, UIColor.clear.cgColor])
}
}
Log
但是,如果您知道它是HTML,为什么要尝试解析JSON?
修复服务器,即使在出现错误的情况下也始终返回JSON,然后再尝试在客户端执行任何操作。
此外,Eclipse长期以来一直被推荐用于Android(持续2年)
答案 1 :(得分:0)
在后端,POST数据被插入到sql中。我相信有一个SQL错误被返回因此
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("barcode", sv.getBarcode()));
params.add(new BasicNameValuePair("scannerid", sv.getScanner()));
params.add(new BasicNameValuePair("loccode", sv.getLoccode()));
params.add(new BasicNameValuePair("longitude", sv.getLong()));
params.add(new BasicNameValuePair("latitude", sv.getLat()));
params.add(new BasicNameValuePair("svtime", sv.getSVTIME()));
JSONObject json = jParser.makeHttpRequest(url_create_svruns,
"POST", params);
Log.d("Create Response", json.toString());
// check for success tag
try {
int success = json.getInt(TAG_SUCCESS);