现在返回的数据:
[{"name":"jack","data":["11","22","33","44"]},{"name":"rose","data":["11","22","33","44"]}]
我想通过 java 后台处理下,返回的数据为:
[{"name":"jack","data":[11,22,33,44]},{"name":"rose","data":[11,22,33,44]}]
后台我如果不用转换 则所有 都不带双引号
getlistmapMsg = JsonTools.getJsonString("json:", Chartlistmap);
未转换 [{name=jack, data=[11, 22, 33, 44]}, {name=rose, data=[11, 22, 33, 44]}]
------解决思路----------------------
那就不能当做json来处理了,用正则匹配吧:
String s = "[{\"name\":\"jack\",\"data\":[\"11\",\"22\",\"33\",\"44\"]},{\"name\":\"rose\",\"data\":[\"11\",\"22\",\"33\",\"44\"]}]";
String regex = "\"(\\d+)\"";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(s);
while (matcher.find()) {
String group = matcher.group();
s = s.replace(group, group.substring(1, group.length() - 1));
}
System.out.println(s);