Home > Web Front-end > JS Tutorial > body text

json introduction js simple example_json

WBOY
Release: 2016-05-16 18:39:43
Original
1083 people have browsed it

The json format is very suitable for simple objects with some properties and values. Here is a simple example:


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh before executing
]
<script> var person={ //json对象定义开始 name:"脚本之家", //字符串 url:"www.jb51.net", //数字 age:"3", married:false, //布尔值 books:[ //数组,在数组中又嵌入了两个json对象 {name:"javascript",price:30}, {name:"正则表达式",price:25} ] } alert(person.books); alert(person.name+" "+person.url+" "+person.age+" "+person.books[0]["name"]); </script>The json object was successfully run and obtained Internal property value. It can be seen that the json object is very simple and easy to learn.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template