PARSE JSON(编码基础64)Android中的STRING

时间:2017-10-08 16:19:49

标签: php android json parsing

**$sql = 'select * from dish_category';
$results =$conn->query($sql);
$spots = array();  //array to parse jason from
while($spot = $results->fetch_assoc()){
     $spots[] = $spot;                                                           
    }

    foreach($spots as $key=>$value){
    $newArrData[$key] =  $spots[$key];
    $newArrData[$key]['Cat_Image'] = base64_encode($spots[$key]['Cat_Image']);
}
header('Content-type: application/json');
echo json_encode($newArrData);**

上面是PHP代码,它工作得很好并返回JSON字符串,现在我很困惑如何解析android中的图像(解码base64)?

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

 byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
 Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, 
 decodedString.length);