You must use OBJ[XX to obtain a value for a key that is a numeric or characters variable character, such as a space.
Copy Code code as follows:
<?php
Declaring JSON data
$array = Array (' Result ' =>array ("=>" "90 Queues", "status" => "Success"));
$json = Json_encode ($array);
$array 1 = Array ("=>", "90 Queues", "status" => "Success");
$json 1 = json_encode ($array 1);
$phpjson = Json_decode ($json 1,true);//The second argument is true, which means converting the JSON data to an array
For JSON key names are numbers, you can only handle $phpjson[' 90 ' by array;
?>
<! DOCTYPE unspecified public "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<body>
<script type= "Text/javascript" >
/**
* Test JSON data invocation sample
*/
function Test () {
Call Way One
var data = ' <?php echo $json?> ';//php json, only single quotes here, because PHP has double quotes in its JSON data.
data = eval ("(+data+)");//js parse JSON data, mainly because the JSON data becomes a string after single quotes
Alert (data[' result '][90]);//For numbers need to be accessed in array mode
Alert (data[' result '].status)://For non-digits can be used to access
Call Mode Two
var data1 = <?php echo $json 1?>;//php JSON data, there is no single quotation mark, because it is directly JSON data
Alert (data1[90]);//For numbers need to be accessed in array mode
alert (data1.status);//For non-digits can be used to access
Alert (data1[' status ');//can also be called using an array method
Note: You must use OBJ[XX to get the value for the key name is numeric or characters variable character (if there is a space).
}
</script>
<input type= "button" value= "button" onclick= "Test ();" />
</body>