서버와 소켓통신으로 데이터를 받아옵니다.
그 데이터는
{ "d_name" : "aaa" , "d_id" : "111" , "ip" : "127.0.0.1" , ... }
{ "d_name" : "bbb" , "d_id" : "222" , "ip" : "192.0.0.0" , ... }
{ "d_name" : "aaa" , "d_id" : "111" , "ip" : "127.0.0.1" , ... }
{ "d_name" : "aaa" , "d_id" : "111" , "ip" : "127.0.0.1" , ... }
|
이런 json 형태로 하나씩 넘어와서 string 으로 받아서 arraylist 에 add 시켰습니다.
그리고 그걸 HashSet 으로 중복 체크하고 다시 json 으로 받아서 파싱하여
최종 데이터를 Listview 에 뿌려야 합니다.
문제는 최종 데이터를 Json 으로 파싱하려고 보면
[ "{\"d_name\":\"aaa\",\"d_id\":\"111\",\"ip\":\"127.0.0.1\",...}" , "{\"d_name\":\"bbb\",\"d_id\":\"222\",\"ip_address\":\"192.0.0.0\",.....}"
|
이런식으로 넘어와서 파싱이 안되고 있습니다.
하루종일 찾아봐도 도무지 모르겠네요,,, 조언좀 부탁드립니다. ㅠㅠ
private ArrayList<String> arr = null ;
DatagramPacket packet = new DatagramPacket(buf, buf.length);
socket.receive(packet);
String str = new String(packet.getData(), 0 , packet.getLength());
if (str.length() > 0 ) {
arr.add(s);
}
....
HashSet hashSet = new HashSet(mArr);
ArrayList ar = new ArrayList(hashSet);
Collections.sort(ar);
testP(ar);
...
private boolean testP(ArrayList<String> ar){
try {
JSONArray ja = new JSONArray(ar);
for ( int i = 0 ; i < ja.length(); i++){
<span style= "color:#FF0000" >
}
} catch (JSONException e){
}
|
방법론이나 힌트라도 부탁드릴께요
감사합니다.