{"college1":{"data":[{"id":"1","name":"nithin","location":"kannur s","time":"2016-06-20 12:06:30"},{"id":"2","name":"riy","location":"sdsdvxc","time":"2016-06-20 12:49:52"},{"id":"3","name":"royop","location":"kjpooj","time":"2016-06-20 06:15:36"},{"id":"4","name":"butr","location":"kjpooj","time":"2016-06-20 06:16:52"},17:17:03"}],"last_date":["2016-06-20 18:18:15"]}}
json数据
try
{
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("lasttime",lasttime));
HttpClient httpClient = new DefaultHttpClient();
HttpPost post = new HttpPost(ip);
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpClient.execute(post);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
String result="";
if(is !=null)
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
while((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
result = sb.toString();
is.close();
我正在尝试开发与android和wamp的通信。当试图将sqlite日期发送到mysql数据库时。它显示此错误消息。这是我的网络服务。
$latest = '';
$datetime=mysql_query("SELECT MAX(time) AS latest from college1");
while ($row = mysql_fetch_assoc($datetime))
{
$latest = $row['latest'];
}
if(isset($_POST['lasttime']))
{
$dates=$_POST['lasttime'];
$datetime=mysql_query("SELECT * from college1 WHERE time > '{$dates}'");
while ($row = mysql_fetch_assoc($datetime))
{
//print_r($row);
//$array1[] = $row;
$retArr['college1']['data'][] = $row;
$retArr[$row['id']] = $row;
$retArr[$row['id']]['latest'] = $latest;
}
$retArr = json_encode($retArr);
echo $retArr;
//echo($retArr);
}
mysql_close($con);
?>
org.json.JSONException:org.json.JSONArray类型的Value []无法转换为JSONObject。 将数据传递给服务器并将其作为空值
时显示此错误