我有以下代码,通常可以正常工作:
HttpPost post = new HttpPost(sendURL);
StringEntity se = new StringEntity( postJSON.toString(), "UTF-8");
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
post.setEntity(se);
response = httpClient.execute(post);
当postJSON有以下内容时,我收到IllegalStateException,并显示消息“Manager已关闭”:
{"action":"add","items":["61515"],"screen":"display","customer_number":"200001013"}
当items数组内容格式错误时,我收到了类似的消息,但我没有看到问题。此外,响应是立即的,所以我很确定HTTP库抛出异常,而不是服务器。这个JSON对象有什么问题?
此外,在JSONLint测试JSON向我展示了JSON正确分析,包括带有“61515”的数组,这是代码中的新元素。