사본 -클립보드 이미지.jpg


위 그림과 같이 org.json.simple.parser 에 JSONParser 클래스가 있음에도 불구하고 참조할 수 없다는 에러가 뜨는 것 같습니다..

이유를 모르겠습니다.. ㅠㅠ 도와주세요.....


   private NaverDAO naverDAO = new NaverDAO();


이게 MainActivity.java의 38번째 줄 입니다..

그리고 아래는


NaverDAO.java 소스입니다..

 

 


 package com.nozisim.pt.dao;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import android.content.Context;
import com.nozisim.pt.domain.Const;
import com.nozisim.pt.domain.LaneVO;
import com.nozisim.pt.domain.LocationVO;
import com.nozisim.pt.domain.PathVO;
import com.nozisim.pt.domain.SubPathVO;
import com.nozisim.pt.util.Http;
import com.nozisim.pt.util.JsonUtil;
public class NaverDAO {
 public Context ctx;
 public List<LocationVO> getLocationSearchList(String key) {
  List<LocationVO> list = new ArrayList<LocationVO>();
  try {
   key = URLEncoder.encode(key, "utf-8");
   String result = Http.doGet(Const.LOCATION_SEARCH_URL, "menu=route&query=" + key, 3000);
   System.out.println(result);
   list = parseLocationList(result);
  } catch (Exception e) {
   e.printStackTrace();
  }
  return list;
 }
 public List<PathVO> getPathSearchList(LocationVO start, LocationVO destination) {
  List<PathVO> list = new ArrayList<PathVO>();
  try {
   String param = "start=" + start.getX() + "%2C" + start.getY() + "%2C"
    + URLEncoder.encode(start.getName(), "utf-8");
   param += "&destination=" + destination.getX() + "%2C" + destination.getY() + "%2C"
    + URLEncoder.encode(destination.getName(), "utf-8");
   String result = Http.doGet(Const.PATH_SEARCH_URL, param, 3000);
   result = correctJson(result);
   list = parsePathList(result);
  } catch (Exception e) {
   e.printStackTrace();
  }
  return list;
 }
 private List<PathVO> parsePathList(String result) {
  List<PathVO> list = new ArrayList<PathVO>();
  try {
   JSONParser parser = new JSONParser();
   JSONObject o = (JSONObject)parser.parse(result);
   o = JsonUtil.getObject(o, "result");
   JSONArray pathList = JsonUtil.getArray(o, "path");
   for (int i = 0; i < pathList.size(); i++) {
    JSONObject joPath = (JSONObject)pathList.get(i);
    JSONObject joPathInfo = JsonUtil.getObject(joPath, "info");
    PathVO path = new PathVO();
    path.setBusStationCount((String)joPathInfo.get("busStationCount"));
    path.setBusTransitCount((String)joPathInfo.get("busTransitCount"));
    path.setFirstStartStation((String)joPathInfo.get("firstStartStation"));
    path.setLastEndStation((String)joPathInfo.get("lastEndStation"));
    path.setPathType((String)joPathInfo.get("pathType"));
    path.setPayment((String)joPathInfo.get("payment"));
    path.setSubwayStationCount((String)joPathInfo.get("subwayStationCount"));
    path.setSubwayTransitCount((String)joPathInfo.get("subwayTransitCount"));
    path.setTotalDistance((String)joPathInfo.get("totalDistance"));
    path.setTotalStationCount((String)joPathInfo.get("totalStationCount"));
    path.setTotalTime((String)joPathInfo.get("totalTime"));
    path.setTotalWalk((String)joPathInfo.get("totalWalk"));
    path.setTrafficDistance((String)joPathInfo.get("trafficDistance"));
    JSONArray subPathList = JsonUtil.getArray(joPath, "subPath");
    for (int j = 0; j < subPathList.size(); j++) {
     JSONObject joSubPath = (JSONObject)subPathList.get(j);
     SubPathVO subPathVO = new SubPathVO();
     subPathVO.setDistance((String)joSubPath.get("distance"));
     subPathVO.setDoor((String)joSubPath.get("door"));
     subPathVO.setEndId((String)joSubPath.get("endID"));
     subPathVO.setEndName((String)joSubPath.get("endName"));
     subPathVO.setEndX((String)joSubPath.get("endX"));
     subPathVO.setEndY((String)joSubPath.get("endY"));
     subPathVO.setGuide((String)joSubPath.get("guide"));
     subPathVO.setSectionTime((String)joSubPath.get("sectionTime"));
     subPathVO.setStartId((String)joSubPath.get("startID"));
     subPathVO.setStartName((String)joSubPath.get("startName"));
     subPathVO.setStartX((String)joSubPath.get("startX"));
     subPathVO.setStartY((String)joSubPath.get("startY"));
     subPathVO.setStationCount((String)joSubPath.get("stationCount"));
     subPathVO.setTrafficType((String)joSubPath.get("trafficType"));
     subPathVO.setWay((String)joSubPath.get("way"));
     LaneVO lane = new LaneVO();
     if (subPathVO.getTrafficType().equals("1")) {
      JSONObject joLane = JsonUtil.getObject(joSubPath, "lane");
      lane.setName((String)joLane.get("name"));
      lane.setSubwayCode((String)joLane.get("subwayCode"));
     } else if (subPathVO.getTrafficType().equals("2")) {
      JSONObject joLane = JsonUtil.getObject(joSubPath, "lane");
      lane.setBusId((String)joLane.get("busID"));
      lane.setBusNo((String)joLane.get("busNo"));
      lane.setType((String)joLane.get("type"));
     }
     subPathVO.setLane(lane);
     path.addSubPath(subPathVO);
    }
    list.add(path);
   }
  } catch (Exception e) {
   e.printStackTrace();
  }
  return list;
 }
 private static List<LocationVO> parseLocationList(String result) {
  List<LocationVO> list = new ArrayList<LocationVO>();
  try {
   JSONParser parser = new JSONParser();
   JSONObject o = (JSONObject)parser.parse(result);
   o = JsonUtil.getObject(o, "result");
   o = JsonUtil.getObject(o, "site");
   if (o == null) {
    return list;
   }
   JSONArray array = JsonUtil.getArray(o, "list");
   for (int i = 0; i < array.size(); i++) {
    JSONObject location = (JSONObject)array.get(i);
    LocationVO item = new LocationVO();
    item.setName((String)location.get("name"));
    item.setAddress((String)location.get("address"));
    item.setX((String)location.get("x"));
    item.setY((String)location.get("y"));
    list.add(item);
   }
  } catch (ParseException e) {
   e.printStackTrace();
  }
  return list;
 }
 public static void main(String[] args) throws UnsupportedEncodingException, ParseException {
  NaverDAO naverDAO = new NaverDAO();
  List<LocationVO> start = naverDAO.getLocationSearchList("정자역");
  List<LocationVO> end = naverDAO.getLocationSearchList("우장산역");
  List<PathVO> list = naverDAO.getPathSearchList(start.get(0), end.get(0));
 }
 public static String correctJson(String jsonValue) {
  //  Set set = new HashSet();
  //  String regex = "[a-zA-Z]+:";
  //  Pattern p = Pattern.compile(regex);
  //  Matcher m = p.matcher(jsonValue);
  //  while (m.find()) {
  //   String g = m.group();
  //   if (set.contains(g)) {
  //    continue;
  //   }
  //   set.add(g);
  //
  //   String key = g.replace(":", "");
  //   jsonValue = jsonValue.replaceAll(g, "\"" + key + "\"" + ":");
  //  }
  jsonValue = jsonValue.replaceAll("([a-zA-Z]+):", "\"$1\":");
  //  jsonValue = jsonValue.replaceAll("[a-zA-Z]+:", "\"$0\":");
  return jsonValue;
 }
}