JSONObject jsonObject = new JSONObject();
jsonObject.put("type", 1);
resp.setLink(new Link(5, surveyId, "COLLECT_PAGE", jsonObject.toJSONString()));
public Link(Integer type, String id, String url, String params) {
this.type = type;
this.id = id;
this.url = url;
this.isClear = isClear;
this.params = params;
}
处理这种请求link的
"link":{
"id":null,
"isClear":false,
"params":"{\"type\":1}",
"type":5,
"url":"COLLECT_PAGE"
}
所以前端这种json格式,Java处理可以
JSONObject 对象用来解决
"{\"type\":1}"
JSONObject jsonObject = new JSONObject();
jsonObject.put("type", 1);
还有这样可以去接受前端传来json 但只给了你String
List<KeyValueData> categoryList = JSONObject.parseArray(categoryInfo, KeyValueData.class);