My code so far:
/apis/get_json.php returns:
{"1":"value1","2":"value2","3":"value3"}
as an array to json in PHP (json_encode).
<script>
$(document).ready(function(){
$.get("/apis/get_json.php",function(json_response,status){
var json_response=JSON.parse(json_response)
alert("Data: " + json_response.[1] + "\nStatus: " + status);
});
});
</script>
I get the error : Uncaught SyntaxError: Unexpected token [
Not sure what the syntax is if the key is numeric
$or_, followed by any of those or a number. A number can't be first, probably to avoid an ambiguity that the parser must then deal with since.9would look like either a valid decimal number or a valid property. Using square brackets, any value can be used, though its toString evaluation is what is ultimately used.