---
title: "json数据结构"
author: "submaze"
date: "2013-06-06T16:42:14Z"
tags: []
categories: ["Web前端"]
slug: "json"
draft: false
lastmod: "2013-06-06T16:51:03Z"
id: 1883306
url: "https://submaze.iteye.com/blog/1883306"
---

```js

<script>
//=====1==============
//json 语法 create obj
var p = {
	"name":'yeeku',
	"gender":'male'
	};
//alert(p.name);

//=====2==============
//json create obj
person = {
	name:'yeeku',
	gender:'male',
	//使用json对象为其指定一个属性
	son:{
		name:'nono',
		grade:1
	},
	//使用json语法为person直接分配一个方法
	info:function(){
		document.writeln("姓名："+this.name+"性别："+this.gender);	
	}
}
//json语法创建数组  以[开始,以]结束
var a = ['yeeku','nono'];

//=======3===============
//复杂json对象
var jsonobj ={
	name:'wawa',
	age:29,
	//定义第三个属性，数组
	schools:['小学','中学','大学'],
	//定义第四个属性，对象数组
	parents:[
		{
			name:'father',
			age:60,
			address:'广州'
		},
		{
			name:'mother',
			age:58,
			address:'深圳'
		}
	]
}
alert(jsonobj.schools[1]);
alert(jsonobj.parents[0].name);

</script>

```