请给我一个有效的方法将下面的String转换为Arraylist,(它作为来自axis2 webservice的响应)
[[
[1],
[<2254, 89014103211118510720, C, D>],
[<100, Colombo 01 , Western, 6.9378, 79.8436, Colombo 01 , Colombo>, <11680, Kirillawala, Western, 0, 0, Kirillawala, Colombo>, <11684, Wattala, Western, 0, 0, Wattala, Colombo>, <11686, Kadawatha, Western, 0, 0, Kadawatha, Colombo>, <11687, Kelaniya, Western, 0, 0, Kelaniya, Colombo>, <11688, Heiyanthuduwa, Western, 0.7, 0.77, Heiyanthuduwa, Colombo>, <11690, Rajagiriya, Western, 0, 0, Rajagiriya, Colombo>, <20034, Yatihalagala, Central, 7.2916415, 80.5988306, Yatihalagala, KANDY>, <20730, Rikillagaskada, Central, 7.15, 80.7833333, Rikillagaskada, KANDY>, <20900, Teldeniya, Central, 7.3, 80.7666667, Teldeniya, KANDY>, <33333, Kesbawa, Western, 0, 0, Kesbawa, Colombo>, <44444, Hanwalla, Western, 0, 0, Hanwalla, Colombo>],
[<VIZA_PP, VIZA_IDD PREPAID CARD, A, 99977>, <VOUCHER, GIFT VOUCHER, A, 99970>, <BRDB_PP, Broadband Pre Paid Card, A, 99995>, <CDMA_PP, CDMA Pre Paid Card, A, 99996>, <BELLKD, Bellkard, A, 99999>],
[<10002#jei#col#0#null#null#0#null#0775555335#1#Colombo 04 >, <10003#test#grdaj#1#6.9098358#79.8513162#2254#2013-10-29#7700555633#1#Colombo 01 >, <10024#uuu#tu#0#null#null#0#null#9999999999#1#Colombo 08 >, <10027#gg#jhh#0#null#null#0#null#0712654789#1#Colombo 08 >, <10028#test1#colpitiya#0#null#null#0#null#0712345678#1#Colombo 08 >, <10029#amal#add1#0#null#null#0#null#0712456186#1#Colombo 01 >, <10030#dinesh chandimal#aaa#1#6.9378#79.84359833333333#2254#2013-05-06#9999999999#1#Colombo 01 >, <10031#Randika Perera#rrr#1#6.9378#79.84359833333333#2254#2013-06-03#7756574766#1#Colombo 01 >, <10032#Indika Herath#ttt#0#null#null#0#null#6834567892#1#Colombo 01 >, <10033#jghg#ghjghj#1#6.9378#79.84359833333333#2254#2013-05-06#8797797898#1#Colombo 01 >, <10037#senarath#hgjghjghjg#0#null#null#0#null#4544544544#1#Colombo 01>, <10039#nimantha#rtyutr#0#null#null#0#null#8798789887#1#Colombo 01 >, <10040#yyy#hgfhf#0#null#null#0#null#9889898889#1#Colombo 01 >, <10041#GAMINI DISSANAYAKE#Colombo#1#6.9378#79.84359833333333#2254#2013-09-24#0733345699#1#Colombo 01 >, <10042#roshan udaya#colombo01#1#6.9378#79.84359833333333#2254#2013-09-24#0772123456#1#Colombo 01 >, <10043#Sanjaya#Kadawatha#1#6.9378#79.84359833333333#2254#2013-05-30#0773333480#1#Colombo 01 >, <10044#aaa#bbb#1#6.9053231#79.8513079#2254#2013-08-27#7777777777#1#Colombo 01 >, <10045#ggg#yyy#1#6.90808663#79.85050531#2254#2013-08-23#9999999999#1#Colombo 01 >, <10046#suresh#borella#0#null#null#0#null#0712345678#1#Colombo 01 >, <10047#buddika#kohuwala#1#6.9378#79.84359833333333#2254#2013-06-03#7777777777#1#Colombo 01 >, <10048#Udeshika#Rajagiriya#0#null#null#0#null#7777777777#1#Colombo 01 >, <10049#SuperLink#Galle Road, Bamba#1#6.9378#79.84359833333333#2254#2013-06-27#0112543764#1#Colombo 01 >, <10235#qqq#qqq#1#6.90809226#79.85048474#2254#2013-08-23#8714444444#1#Colombo 01 >, <10236#wwww#wwwww#1#6.9378#79.84359833333333#2254#2013-09-24#8774444444#1#Colombo 01 >, <10237#rrr#rrr#0#null#null#0#null#2255558888#1#Colombo 01 >, <10238#aaa#aaa#0#null#null#0#null#0717177777#1#Colombo 01 >, <10239#bbb#bbb#0#null#null#0#null#0777777777#1#Colombo 01 >, <10240#ccc#ccc#1#6.9378#79.84359833333333#2254#2013-09-24#0778888888#1#Colombo 01 >, <10241#ddd#ddd#1#6.9040059#79.85238#2254#2013-08-27#0088855555#1#Colombo 01 >, <10242#eee#eee#1#6.9040059#79.85238#2254#2013-08-27#9966655577#1#Colombo 01 >, <10243#Niraj#Nittabuwa#1#6.9378#79.84359833333333#2254#2013-09-24#7777712133#1#Colombo 01 >, <10244#Dilum#Kohuwala#0#null#null#0#null#1111111111#1#Kadawatha>, <10246#Namala#Namal Uyana#0#null#null#0#null#1111111111#1#Colombo 01 >, <10248#abc#abc123#1#6.9378#79.84359833333333#2254#2013-09-24#1111111111#1#Colombo 01 >, <10249#cde#cde123#1#6.9378#79.84359833333333#2254#2013-09-24#1111111111#1#Colombo 01 >, <10250#efg#efg123#1#6.9378#79.84359833333333#2254#2013-09-24#1111111111#1#Colombo 01 >, <10251#A#A1#1#6.9378#79.84359833333333#2254#2013-09-24#1111111111#1#Colombo 01 >, <10252#B#B1#1#6.9378#79.84359833333333#2254#2013-09-24#1111111111#1#Colombo 01 >, <10253#C#C1#1#6.9378#79.84359833333333#2254#2013-09-24#1111111111#1#Colombo 01 >, <10254#D#D1#0#null#null#0#null#1111111111#1#Colombo 01 >, <10255#E#E1#1#6.9378#79.84359833333333#2254#2013-09-24#1111111111#1#Colombo 01 >, <10256#F#F1#0#null#null#0#null#1111111111#1#Colombo 01 >, <10257#G#G1#1#6.9378#79.84359833333333#2254#2013-09-24#1111111111#1#Colombo 01 >, <10258#LankaBell#344 Galle Road#0#null#null#0#null#0777864914#1#Colombo 01 >, <10259#Shamaal#23#0#null#null#0#null#0998766554#1#Kirillawala>, <10260#Namala#123#0#null#null#0#null#0777655443#1#Kelaniya>, <10261#Keshini#324#0#null#null#0#null#0999873564#1#Kelaniya>, <10262#Ruwani#3334#1#6.9378#79.84359833333333#2254#2013-10-14#0776554433#1#Colombo 01 >, <10263#Shamaal #564134877#1#6.9378#79.84359833333333#2254#2013-10-14#0774563555#1#Colombo 01 >, <10264#Amila#6432#0#null#null#0#null#0777436437#1#Colombo 01 >, <10265#Pathum#47#0#null#null#0#null#0000000000#1#Colombo 01 >, <10266#A#100, Kandy Rd, #1#0.0#0.0#2254#2013-10-17#0884754867#1#Kadawatha>, <10267#Hasitha#352/1 old rd#1#0.0#0.0#2254#2013-10-15#0775456323#1#Kelaniya>, <10270#Harshi#dsfdsfgds#0#null#null#0#null#0586756476#1#Colombo 01 >, <10271#yyyyyyyyyyy#yyyyyyyyyyy#0#null#null#0#null#0000000000#1#Colombo 01 >, <10272#ererererer#ererererererererer#0#null#null#0#null#6666666666#1#Colombo 01 >, <10273#SSSSSSS#3535#0#null#null#0#null#0574856475#1#Colombo 01 >, <10275#Chathurika Peris#87, ggttggfhrtr, gfhregygtgiihf#0#null#null#0#null#0775643334#1#Colombo 01 >, <10276#Harith#gdjhgfdhgdsvgd#0#null#null#0#null#0777543234#1#Colombo 01 >, <10277#A#A#0#null#null#0#null#1111111111#1#Colombo 01 >, <10278#TironD#Kurunegala#1#6.9378#79.84359833333333#2254#2013-10-16#9245923482#1#Colombo 01 >, <10279#Hasitha#3#1#6.9378#79.84359833333333#2254#2013-10-16#0775445675#1#Colombo 01 >, <10280#Priyanka#Colombo#1#6.9378#79.84359833333333#2254#2013-10-21#0226567356#1#Colombo 01 >, <10281#Test#Galle rd#0#null#null#0#null#0000000000#1#Colombo 01 >],
[<1, BELLKD>, <50, BELLKD>, <100, BELLKD>, <300, BELLKD>, <500, BELLKD>, <1000, BELLKD>, <2500, BELLKD>, <5000, BELLKD>, <50, CDMA_PP>, <100, CDMA_PP>, <200, CDMA_PP>, <300, CDMA_PP>, <500, CDMA_PP>, <1000, CDMA_PP>, <2500, CDMA_PP>, <5000, CDMA_PP>, <250, N2PHONE>, <500, N2PHONE>, <1000, N2PHONE>, <250, N2P_IND>, <500, N2P_IND>, <1000, N2P_IND>, <250, N2P_MID>, <500, N2P_MID>, <1000, N2P_MID>, <250, N2P_WST>, <500, N2P_WST>, <1000, N2P_WST>, <1, TRITELL>, <50, TRITELL>, <100, TRITELL>, <300, TRITELL>, <500, TRITELL>, <1000, TRITELL>, <2500, TRITELL>, <5000, TRITELL>, <150, VIZA_PP>, <350, VIZA_PP>, <500, VIZA_PP>, <1000, VIZA_PP>, <2500, VIZA_PP>],
[<10041#CDMA_PP#200#6#1#30-10-2013 15:34:24>, <10042#CDMA_PP#200#7#1#30-10-2013 15:21:19>, <10031#CDMA_PP#100#3#1#30-10-2013 15:20:15>, <10047#CDMA_PP#100#2#1#30-10-2013 15:07:22>, <10043#CDMA_PP#100#2#1#30-10-2013 15:05:24>, <10041#CDMA_PP#100#1#1#30-10-2013 14:51:25>, <10049#CDMA_PP#100#3#1#30-10-2013 14:45:26>, <10267#CDMA_PP#100#1#1#30-10-2013 14:44:25>, <10255#CDMA_PP#200#53#1#30-09-2013 15:46:43>, <10243#CDMA_PP#200#43#1#24-09-2013 16:58:02>, <10257#CDMA_PP#200#44#1#24-09-2013 16:58:02>, <10254#CDMA_PP#200#47#1#24-09-2013 16:58:01>, <10248#CDMA_PP#200#90#1#24-09-2013 16:58:00>, <10043#CDMA_PP#200#1#1#24-09-2013 16:45:41>, <10235#CDMA_PP#200#1#1#24-09-2013 16:28:50>, <10044#CDMA_PP#200#1#1#24-09-2013 16:26:57>, <10240#CDMA_PP#200#1#1#24-09-2013 16:25:53>, <10241#CDMA_PP#200#1#1#24-09-2013 16:23:49>, <10242#CDMA_PP#200#1#1#24-09-2013 16:21:49>, <10249#CDMA_PP#200#1#1#24-09-2013 16:16:57>, <10250#CDMA_PP#200#1#1#24-09-2013 16:15:53>, <10251#CDMA_PP#200#1#1#24-09-2013 15:33:35>, <10252#CDMA_PP#200#2#1#24-09-2013 15:32:31>, <10253#CDMA_PP#200#2#1#24-09-2013 15:25:37>, <10030#CDMA_PP#300#1#1#21-10-2013 17:23:41>, <10266#CDMA_PP#300#3#1#17-10-2013 11:06:53>, <10030#CDMA_PP#100#11#3#17-10-2013 11:04:52>, <10003#CDMA_PP#100#2#1#16-10-2013 15:05:47>, <10049#CDMA_PP#200#3#1#15-10-2013 17:07:11>, <10045#CDMA_PP#200#1#1#15-10-2013 16:51:28>, <10042#CDMA_PP#100#9#1#15-10-2013 12:00:05>, <10003#CDMA_PP#300#6#1#14-10-2013 16:47:35>, <10262#CDMA_PP#300#5#3#14-10-2013 10:24:16>, <10030#CDMA_PP#50#4#1#11-11-2013 13:18:54>, <10031#CDMA_PP#200#58#1#11-11-2013 11:19:36>, <10030#CDMA_PP#200#120#1#11-11-2013 11:13:09>, <10255#CDMA_PP#100#1#1#10-10-2013 10:33:08>, <10033#CDMA_PP#200#10#1#08-11-2013 17:58:16>, <10003#CDMA_PP#200#69#1#05-11-2013 12:19:52>],
[22630],
[],
[<12050021, 6057160, 6057164, CDMA_PP, 50, 28-02-2014 12:17:08, 5.5, 0>, <12050020, 6057140, 6057144, CDMA_PP, 50, 28-02-2014 12:17:08, 5.5, 0>, <12050021, 6057150, 6057154, CDMA_PP, 50, 28-02-2014 12:17:08, 5.5, 0>, <12100005, 6003841, 6003850, CDMA_PP, 200, 28-02-2014 12:17:08, 4.5, 0>, <91200256, 6048225, 6048233, CDMA_PP, 300, 28-02-2014 12:17:08, 5.5, 0>]
]]
那些返回String.so如何转换它们如下所示
元素1 = [1],
元素2 = [&lt; 2254,89014103211118510720,C,D&gt;]等。
编辑亲爱的 abmitchell
因为他们从arraylist
获取后会插入到sqlite中String dbQuery20 = result20.getProperty(0).toString();
String[] statusarray3 = dbQuery20.split(",");
String status20Value = statusarray3[0].toString();
String status21Value = statusarray3[1].toString();
String status22Value = statusarray3[2].toString();
String editedValue3 = status20Value.replaceAll("\\[|\\]", "");
int status3 = Integer.parseInt(editedValue3);
if (status3 == 1) {
String userIdValue1 = statusarray3[1].toString();
dbh.SaveLoginData(userIdValue1.replaceAll("\\[|\\]|\\<", ""),
statusarray3[3].toString(),
statusarray3[4].toString().replaceAll("\\[|\\]|\\>",""),
statusarray3[2].toString());
dbh.SetLoginDetailsUpdatedDate(date);
}
}
感谢所有现在可以使用以下代码
s=s.replaceAll("\\[\\[","").replaceAll("]]","");
List<String> arrayList = Arrays.asList(s.split(","));
ArrayList listFinal=new ArrayList(Arrays.asList(arrayList));
System.out.println(listFinal);
答案 0 :(得分:1)
如果没有转换为JSON对象,然后钓掉每个数组,我会做这样的事情:
str = str.substring(2, str.length() - 2); // Get rid of the first and last [[ / ]]
String[] strArray = str.split(",");
答案 1 :(得分:1)
使用他们的武器:
s=s.replaceAll("\\[\\[","").replaceAll("]]","");
List<String> arrayList = Arrays.asList(s.split(","));