JSON array
Translation results:
Array as json object
JSON arraysyntax
JSON arrays are written in square brackets.
Array values in JSON must be legal JSON data types (string, number, object, array, Boolean or null).
In JavaScript, array values can be the above JSON data types, or JavaScript expressions, including functions, dates, and undefined.
JSON arrayexample
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php.cn</title> </head> <body> <p>访问 JSON 对象数组值。</p> <p id="demo"></p> <script> var myObj, x; myObj = { "name":"网站", "num":3, "sites":[ "Google", "php.cn", "Taobao" ] } x = myObj.sites[0]; document.getElementById("demo").innerHTML = x; </script> </body> </html>
Run instance »
Click the "Run instance" button to view the online instance