后台对象:
public ActivityData(Long id,String activityId,String activityName,String activityDesc,String activityPeriod,String activityPageUrl,String activityProds) { this.id= id; this.activityId=activityId; this.activityName=activityName; this.activityDesc= activityDesc; this.activityPeriod=activityPeriod; this.activityPageUrl=activityPageUrl; this.activityProds=activityProds; }
这个activityProds是一个Intermediate类型的对象,此时传值也要是String类型的,解决方法:
String str = "[\n" + " {\"qstId\":\"123\",\n" + " \"sku\":\"amani123\",\n" + " \"prodName\":\"阿瑪尼紅色\"\n" + " },\n" + " {\n" + " \"qstId\":\"123\",\n" + " \"sku\":\"amani123\",\n" + " \"prodName\":\"阿瑪尼紅色\"}\n" + " ]"; JSONArray arr1 = JSONArray.parseArray(str); System.out.println(JSON.toJSONString("'"+arr1+"'"));
输出结果如下:
"'[{\"qstId\":\"123\",\"prodName\":\"阿瑪尼紅色\",\"sku\":\"amani123\"},{\"qstId\":\"123\",\"prodName\":\"阿瑪尼紅色\",\"sku\":\"amani123\"}]'" ,将此值添加作为参数传入即可