前台传入object对象,后台解析数据
var myDatas = new Object();
myDatas={
commodity_name : '1',//产品名称 $('#chanpinmingcheng')
commodity_marketprice : '1',//市场价 $('#shichangjia')
commodity_stock : '1',//产品数量 $('#chanpinshuliang')
commodity_bit : '1',//少量标准1 之数量区间 $('#-'); //select box
commodity_bit_price : '1',//少量标准1 之数量区间价格 $('#cahnpinjiage-01');
commodity_abundance : '1',//大量标准1 之数量区间 $('#-'); //select box
modity_abundance_price : '1',//大量标准1 之数量区间 $('#myjiage1'); //select box
commodity_deliverytime : '1', //发货期 $('#fahuoqi');
commodity_deliveraddress : '1',//发货地 $('#regAddress')
commodity_unit : '1',//产品单位 select box
commodity_class : CookieUtil.get('tag1')+'/'+CookieUtil.get('tag2')+'/'+CookieUtil.get('tag3')
}
$.ajax({
url : getUrl()+'ReleaseProduct',
dataType : 'json',
type : 'get',
data : {
token : CookieUtil.get('token'),
userId : CookieUtil.get('userId'),
category : myDatas
},
success : function(){
console.log('发送成功');
}
})
前台解析数据输出
{"commodity_name":"1","commodity_marketprice":"1","commodity_stock":"1","commodity_bit":"","commodity_bit_price":"1","commodity_abundance":"","modity_abundance_price":"1","commodity_deliverytime":"1","commodity_deliveraddress":"天津","commodity_unit":"","commodity_class":"安全、防护/锁具/自行车锁"}
后台接收到数据解析
public Object ReleaseProduct(String token,long userId,Object category) {
// TODO Auto-generated method stub
if(!IsToken.isToken(token,userId)){
json.put("msg", "身份过期");
return json;
}
System.out.println(Json.toJson(category));
List<Shop_commodity> list=Json.fromJsonAsList(Shop_commodity.class, Json.toJson(category));
shop_commodityDao.addShop_commodityForList(list);
json.put("msg", "产品信息发布成功");
return json;
}
解析的数据
==:java.lang.Object@3c40210a
{
}