Excess JSON response

theboy

New Member
My JSON response seems to have excess keys in it. Any idea why?Here is an excerpt from the JSON response:\[code\]{ "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" },\[/code\]Here is my PHP code:\[code\]$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)); \[/code\]
 
Top