【问题标题】:PARSE JSON (Encode base 64) STRING in Android在 Android 中解析 JSON(编码 base 64)字符串
【发布时间】:2026-02-24 10:20:06
【问题描述】:
**$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)?

【问题讨论】:

    标签: php android json parsing


    【解决方案1】:
     byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
     Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, 
     decodedString.length); 
    

    【讨论】:

      【解决方案2】: