【发布时间】:2011-09-13 11:17:31
【问题描述】:
我正在尝试为我的 android 应用程序创建一个休息服务,其中外部数据库返回要存储在应用程序本地数据库中的项目。除了blob被返回为null之外,我已经完成了所有工作。
这是我的 jason 响应示例。(图片和缩略图字段是 blob)
{"id":"2","user_id":"1","name":"testing","type":"bouldering","picture":null,"lat":"36","long":"81","alt":"41932","accuracy":"53","thumbnail":null}
这是我返回数据的 php 脚本。
<?php
require_once('config.php');
$mysqli = new mysqli(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
$sql = 'select * from spot_main';
$results =$mysqli->query($sql);
$spots = array(); //array to parse jason from
while($spot = $results->fetch_assoc()){
$spots[] = $spot;
}
echo json_encode($spots);
?>
有人知道这个问题的解决方案吗?我知道我这样做不是最有效的方式(最好将图像存储在文件系统中),但我需要这样做。
【问题讨论】:
-
请阅读有关允许符号的 JSON 规范。 json.org
标签: php android mysql json blob