首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

求个JSON格式的构造函数,该如何处理

2012-02-25 
求个JSON格式的构造函数varo{previousMonthEvent :[{ date : 2007-7-4 ,event :[{ hour : 10A

求个JSON格式的构造函数
var   o   =
{
"previousMonthEvent ":
[
{ "date ": "2007-7-4 ",
  "event ":
[
{ "hour ": "10   AM ", "title ": "10   title ", "location ": "10   location ", "description ": "10   description "},
{ "hour ": "2   PM ", "title ": "2   title ", "location ": "2   location ", "description ": "2   description "}
]},

{ "date ": "2007-7-17 ",
"event ":
[
{ "hour ": "7   AM ", "title ": "7   title ", "location ": "7   location ", "description ": "7   description "},
{ "hour ": "1   PM ", "title ": "1   title ", "location ": "1   location ", "description ": "1   description "}
]},
{ "date ": "2007-7-29 ",
  "event ":
[
{ "hour ": "9   AM ", "title ": "9   title ", "location ": "9   location ", "description ": "9   description "},
{ "hour ": "5   PM ", "title ": "5   title ", "location ": "5   location ", "description ": "5   description "}
]}

],

"currentMonthEvent ":
[
{ "date ": "2007-8-6 ",
  "event ":
[
{ "hour ": "9   AM ", "title ": "9   title ", "location ": "9   location ", "description ": "9   description "},
{ "hour ": "5   PM ", "title ": "5   title ", "location ": "5   location ", "description ": "5   description "}
]},

{ "date ": "2007-8   -21 ",
  "event ":
[
{ "hour ": "3   PM ", "title ": "3   title ", "location ": "3   location ", "description ": "3   description "}
]}

],
"nextMonthEvent ":
[
{ "date ": "2007-9-19 ",
  "event ":
[
{ "hour ": "9   AM ", "title ": "9   title ", "location ": "9   location ", "description ": "9   description "},
{ "hour ": "1   PM ", "title ": "1   title ", "location ": "1   location ", "description ": "1   description "},
{ "hour ": "4   PM ", "title ": "4   title ", "location ": "4   location ", "description ": "4   description "}
]},

{ "date ": "2007-9   -20 ",
  "event ":
[
{ "hour ": "8   AM ", "title ": "8   title ", "location ": "8   location ", "description ": "8   description "},
{ "hour ": "9   AM ", "title ": "9   title ", "location ": "9   location ", "description ": "9   description "},


{ "hour ": "5   PM ", "title ": "5   title ", "location ": "5   location ", "description ": "5   description "}
]}

]


};

------

JSON不太了解,勉强能写一个格式,但写与之对应的构造函数暂时没头绪,请高人指点.
要求此构造函数包含增,删,改,查方法,并能前后移动方法(前移:previousMonthEvent变成currentMonthEvent,currentMonthEvent变成nextMonthEvent;nextMonthEvent用新数据代替;而后移反之)

[解决办法]
方法容易...
直接 名:function(){...}就行了...

对于 "构造函数 "...
JSON实际上可以看作一个简写...
var a = {p:v}
相当于
var a = new Object(); //注意这里
a.p = v;
[解决办法]
试试不要用匿名对象咯...
不过看晕了也好...
不用混淆器了...哈哈~~
[解决办法]
up
[解决办法]
http://www.json.org/

这么多.为什么要自己写呢/
[解决办法]
编程动力 www.bcexe.com 专业的编程开发类网站,网络编程,软件开发,网站开发,一切尽在这里!

热点排行