JSON 応答に余分なキーが含まれているようです。理由はありますか?
以下は、JSON 応答からの抜粋です。
{
"0": "1",
"id": "1",
"1": "XX University",
"name": "XX University",
"2": "http:\/\/ree.com\/images\/xxUniversity.png",
"backgroundImageUrl": "http:\/\/ree.com\/images\/XXUniversityLogo.png",
"3": "http:\/\/ree.com\/images\/xxUniversity.png",
"logoImageUrl": "http:\/\/ree.com\/images\/XXUniversityLogo.png"
},
ここに私のPHPコードがあります:
$query = "SELECT * from $entity"; //Bad security,for a different question
$results = mysqli_query($con,$query);
//Parse to JSON
$json=array();
while($row=mysqli_fetch_array($results)){
$json[]=$row;
}
//Close connection
mysqli_close($con);
//Encode and send response as JSON (using the entity type as a parameter)
//echo json_encode(array($entity => $json), JSON_FORCE_OBJECT);
echo json_encode(array ($entity =>$json));