json数据文件的数据格式可以用下边两种方式写:
1.在只有一类数据的情况情况下f.json文件:
[
{"name":"致美丽的你----红玫瑰11枝","pic":1,"price":128,"num":3},
{"name":"夏之物语----香槟玫瑰50枝","pic":2,"price":386,"num":7},
{"name":"为爱相随----百合+黛安娜粉玫瑰","pic":3,"price":186,"num":11},
{"name":"感激----29枝红康乃馨","pic":4,"price":229,"num":8},
{"name":"暖暖情意----粉 {MOD}康乃馨16枝","pic":5,"price":189,"num":24},
{"name":"温馨思念----红 {MOD}康乃馨16枝","pic":6,"price":160,"num":16},
{"name":"爱的祝福","pic":7,"price":188,"num":6},
{"name":"蓝 {MOD}永生玫瑰","pic":8,"price":269,"num":12}
]
2.在多重数据的情况下,就需要嵌套数组,fc.json文件:
{
"flower":[
{"name":"致美丽的你----红玫瑰11枝","pic":1,"price":128,"num":3},
{"name":"夏之物语----香槟玫瑰50枝","pic":2,"price":386,"num":7},
{"name":"为爱相随----百合+黛安娜粉玫瑰","pic":3,"price":186,"num":11},
{"name":"感激----29枝红康乃馨","pic":4,"price":229,"num":8},
{"name":"暖暖情意----粉 {MOD}康乃馨16枝","pic":5,"price":189,"num":24},
{"name":"温馨思念----红 {MOD}康乃馨16枝","pic":6,"price":160,"num":16},
{"name":"爱的祝福","pic":7,"price":188,"num":6},
{"name":"蓝 {MOD}永生玫瑰","pic":8,"price":269,"num":12}
],
"cake":[
{"name":"提拉米苏(8寸)","pic":1,"price":128,"num":3},
{"name":"恋爱的心(6寸)","pic":2,"price":386,"num":7},
{"name":"柳橙慕斯(8寸)","pic":3,"price":186,"num":11},
{"name":"臻爱礼盒(6寸)","pic":4,"price":229,"num":8},
{"name":"四重奏蛋糕(8寸)","pic":5,"price":189,"num":24},
{"name":"你好米菲蛋糕(1磅)","pic":6,"price":160,"num":16},
{"name":"蓝莓轻乳蛋糕(1磅)","pic":7,"price":188,"num":6},
{"name":"在一起(8寸)","pic":8,"price":269,"num":12}
]
}