jsonp 返回以前必须要再转一次json
public static void main(String[] args) {
String ajaxJsonStr = null;
AjaxJson ajaxJson = new AjaxJson();
ajaxJson.setMsg("成功");
ajaxJson.setSuccess(true);
ajaxJsonStr = "jQuery19108564255327945463_1514776803167" + "(" + JSON.toJSONString(ajaxJson) + ")";
System.out.println(ajaxJsonStr);
String jsonString = JSON.toJSONString(ajaxJsonStr);
System.out.println(jsonString);
}
运行结果:
jQuery19108564255327945463_1514776803167({"msg":"成功","success":true})
"jQuery19108564255327945463_1514776803167({\"msg\":\"成功\",\"success\":true})"