JSON format data is transmitted from the foreground to the background

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

Guess you like

Origin blog.csdn.net/qq_39839828/article/details/105692990