I am having trouble using Alamofire in iOS because because my php seems to not be returning valid json. I have added the header "header("Content-Type: application/json; charset=utf-8");" before encoding array but it still does not work. If it matters some columns in my database table are encoding using utf8mb4_unicode_ci. Here is my php:
<?php
$con = mysqli_connect("localhost","hide","hide","hide");
mysqli_set_charset($con, "utf8");
if(mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "SELECT * FROM Business";
if($result = mysqli_query($con, $sql))
{
$resultArray = array();
$tempArray = array();
while($row = $result->fetch_object())
{
$tempArray = $row;
array_push($resultArray, $tempArray);
}
header("Content-Type: application/json; charset=utf-8");
echo json_encode($resultArray);
}
mysqli_close($result);
mysqli_close($con);
?>
Unformatted json:
[{"business_id":"0","imageURL":"imageUrl","shortDescription":"shortDescription","longDescription":"longDescription","price":"price","specialText":"specialText","order_rank":"1"}]
Here is formatted json specifying error: