var sys_item = {
"mktprice": "13.00",
"price": "6.80",
"sys_attrprice": {
"3_13": {
"price": "6.80",
"mktprice": "13.00"
},
"3_14": {
"price": "7.80",
"mktprice": "14.00"
},
"3_16": {
"price": "8.80",
"mktprice": "15.00"
},
"3_17": {
"price": "9.80",
"mktprice": "16.00"
},
"4_13": {
"price": "6.80",
"mktprice": "13.00"
},
"4_14": {
"price": "7.80",
"mktprice": "14.00"
},
"4_16": {
"price": "8.80",
"mktprice": "15.00"
},
"4_17": {
"price": "9.80",
"mktprice": "16.00"
},
"8_13": {
"price": "6.80",
"mktprice": "13.00"
},
"8_14": {
"price": "7.80",
"mktprice": "1400"
},
"8_16": {
"price": "8.80",
"mktprice": "15.00"
},
"8_17": {
"price": "9.80",
"mktprice": "16.00"
},
"9_13": {
"price": "6.80",
"mktprice": "13.00"
},
"9_14": {
"price": "7.80",
"mktprice": "14.00"
},
"9_16": {
"price": "8.80",
"mktprice": "15.00"
},
"9_17": {
"price": "9.80",
"mktprice": "16.00"
},
"10_13": {
"price": "6.80",
"mktprice": "13.00"
},
"10_14": {
"price": "7.80",
"mktprice": "14.00"
},
"10_16": {
"price": "8.80",
"mktprice": "15.00"
},
"10_17": {
"price": "9.80",
"mktprice": "16.00"
},
"12_13": {
"price": "6.80",
"mktprice": "13.00"
},
"12_14": {
"price": "7.80",
"mktprice": "14.00"
},
"12_16": {
"price": "8.80",
"mktprice": "15.00"
},
"12_17": {
"price": "9.80",
"mktprice": "16.00"
}
}
};
上面当我选中:
颜色的data-aid为3,规格的data-aid为13时,默认价格更新为3_13对应的价格
data-aid为3, 规格的data-aid为14时,默认价格更新为3_14对应的价格
data-aid为4, 规格的data-aid为13时,默认更新为4_13对应的价格
第二种:
{
"library":[
{
"product_color":"625",
"product_spec":"626",
"buyer":"46.15",
"attribute":"0"
},
{
"product_color":"625",
"product_spec":"627",
"buyer":"46.15",
"attribute":"0"
},
{
"product_color":"625",
"product_spec":"628",
"buyer":"50.00",
"attribute":"1"
},{
"product_color":"629",
"product_spec":"627",
"buyer":"33.00",
"attribute":"0"
}
]
}
默认
颜色product_color: 625
规格product_spec: 627
价格为46.15
当选择product_color: 625, 规格为628,对应价格为50.00
当选择product_color: 629, 规格为627,对应的价格为33.00
这两种json数据格式那种更为简洁,效率更高效?
有数据冗余重复的时候,尽量消除数据的重复。上面的两种数据组织方式都没有冗余,但是为了查询方便,数据格式的组织可以像数据库一样,有一个便于查询的主键,也可以说是id。所以个人感觉上面的那种方式好一点,可以直接通过key查到value。而下面的那种方式感觉查询起来有些麻烦。
数据格式的组织也尽量范式化:
上面的引用是来自Redux官方文档推荐的state组织方式,可以参考一下。