try 블록에 업데이트되지 객체와 I는 다음과 같이 표시하는 API에서 시간표 정보를 분석하려고 : 나는 실행하고구문 분석 JSON 객체는, 내가 대학 프로젝트를 진행하고
"1474239600000" : {
"courseCode" : "CASE4",
"moduleCodes" : [ "CareersService" ],
"moduleDescription" : "Careers Svs. slots in ALL Year 4s",
"startTime" : 1474286400000,
"endTime" : 1474290000000,
"locations" : [ "GLA.XG21", "GLA.Q119" ],
"type" : "SEMINAR"
}
분석 안드로이드 액티비티의 AsyncTask에있는 코드. 나는 강의 객체 LEC를 반환 할 때 try 블록에 할당 된 값하지만 강의로 설정 한 디폴트 값을 표시되지,
protected Lecture doInBackground(String... urls) {
Lecture lec = new Lecture();
try{
BufferedReader in = new BufferedReader(
new FileReader("json.txt"));
String inputLine;
String content = "";
while ((inputLine = in.readLine()) != null) {
content = content + inputLine;
System.out.println(inputLine);
//Log.d("INPUT:",inputLine);
}
JSONObject obj = new JSONObject(content);
String courseCode = obj.getString("courseCode");
String moduleDescription = obj.getString("moduleDescription");
String type = obj.getString("type");
lec = new Lecture(courseCode,"TEST",moduleDescription,type);
}catch(Exception e){
Log.e("JSON PARSER:","CATCH ERROR");
e.printStackTrace();
}
return lec;
}
: 여기에 내가이 일을 수행 한 코드입니다. 내가 어떤 가능한 도움을 부탁드립니다
,
감사합니다, 라이언.
은 귀하의 문제에서 설명한 JSON입니까? 그렇다면 형식이 잘못되었습니다. 나는 또한 당신이 예외를 받고 응용 프로그램이 try 블록 전체를 실행하지 않는다고 가정합니다. – BrickTop
이 응용 프로그램이 try 블록을 입력하지 않는 이유에 대해 알고 계십니까? –
@BrickTop \t 이 응용 프로그램이 try 블록을 입력하지 않는 이유는 무엇입니까? –