极客们,
我在java中有一个字符串,它的值如下
{“organizationName”:“备件-展厅销售,Uaq","organizationCode":"S05","retailPrice":"32","onHandQuantity":"0","index":1} {”organizationName“:”备件-展厅销售,HiQ Shj EMR","organizationCode":"S18","retailPrice":"32","onHandQuantity":"0","index":2} {“organizationName”:“备件-展厅销售,Dxb","organizationCode":"S16","retailPrice":"32","onHandQuantity":"0",“索引”:3}{“organizationName”:“备件陈列室销售,Dib","organizationCode":"S17","retailPrice":"32","onHandQuantity":"0",”索引“:4}{”organizationName“:”备件中心零件库“,"organizationCode":"S01","retailPrice":"32","onHandQuantity":"0",“索引”:5}{“organizationName”:“备件-展厅销售额,Awr","organizationCode":"S02","retailPrice":"32","onHandQuantity":"0",”索引“:6}{”organizationName“:”备件-展厅销售额,Shj","organizationCode":"S03","retailPrice":"32","onHandQuantity":"0",“索引”:7}{“organizationName”:“备件-展厅销售额,Ajm","organizationCode":"S04","retailPrice":"32","onHandQuantity":"0",“索引”:8}{“organizationName”:“备件-展厅销售额,Rak","organizationCode":"S06","retailPrice":"32","onHandQuantity":"0",”索引“:9}{”organizationName“:”备件-展厅销售额,Kal","organizationCode":"S07","retailPrice":"32","onHandQuantity":"0",“索引”:10}{“organizationName”:“备件-展厅销售,Fuj","organizationCode":"S08","retailPrice":"32","onHandQuantity":"0",”索引“:11}{”organizationName“:”备件-展厅销售,Kho","organizationCode":"S09","retailPrice":"32","onHandQuantity":"0",“索引”:12}{“organizationName”:“备件-展厅销售,Dhd","organizationCode":"S10","retailPrice":"32","onHandQuantity":"0",“索引”:13}{“organizationName”:“备件-展厅销售额,周六”,"organizationCode":"S11","retailPrice":"32","onHandQuantity":"0",“索引”:14}{“organizationName”:“备件-展厅销售额,Gus","organizationCode":"S12","retailPrice":"32","onHandQuantity":"0",“索引”:15}{“organizationName”:“备件-展厅销售,Szr","organizationCode":"S13","retailPrice":"32","onHandQuantity":"0",”索引“:16}{”organizationName“:”备件-展厅销售,HiQ MSF","organizationCode":"S19","retailPrice":"32","onHandQuantity":"0",“索引”:17}{“organizationName”:“备件-配件,PDI","organizationCode":"S21","retailPrice":"32","onHandQuantity":"0",“索引”:18}
如何为每个表示获取字符串对象,如{“organizationName”:“备件-附件,PDI","organizationCode":"S21","retailPrice":"32","onHandQuantity":"0","index":18}
所以基本上我会从上面得到18个String对象。
谢谢
发布于 2017-03-14 21:05:56
您可以尝试提取大括号之间的值,并将其格式化为json
String s1 = ""; //your string
Pattern pattern = Pattern.compile("\\{(.*?)}");
Matcher matcher = pattern.matcher(s1);
while (matcher.find()) {
String.format("{%s}", matcher.group(1));
}https://stackoverflow.com/questions/42786072
复制相似问题