Background objects:
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; }
This activityProds is an object of type Intermediate, and the value passed at this time should also be of type String. Solution:
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+"'"));
The output is as follows:
"'[{\"qstId\":\"123\",\"prodName\":\"Armani Red\",\"sku\":\"amani123\"},{\"qstId\":\ "123\",\"prodName\":\"Armani Red\",\"sku\":\"amani123\"}]'", add this value as a parameter and pass in