Facebookへのリクエストから与えられたフィードを解析しようとしています。しかし、私のパーサーは多くの情報をスキップしています。以下は、コードの一部であり、解析されているものと、ifステートメントで出力されているものの例です。たとえば、「メッセージ」は見つかりません。アイデア?
List<FacebookItem> list = new ArrayList<FacebookItem>();
try {
if (jFactory == null)
jFactory = new JsonFactory();
jParser = jFactory.createJsonParser(json);
FacebookItem o = null;
while (jParser.nextToken() != null) {
if ("type".equals(jParser.getCurrentName())) {
jParser.nextToken();
o = new FacebookItem();
o.setType(jParser.getText());
System.out.println("Found type: " + jParser.getText());
}
if ("from".equals(jParser.getCurrentName()))
while (!"name".equals(jParser.getCurrentName())) {
jParser.nextToken();
}
jParser.nextToken();
o.getUser().setUserName(jParser.getText());
System.out.println("Found name: " + jParser.getText());
}
if ("message".equals(jParser.getCurrentName())) {
jParser.nextToken();
o.setText(jParser.getText());
System.out.println("Found message: " + jParser.getText());
}
if ("created_time".equals(jParser.getCurrentName())) {
jParser.nextToken();
o.setTimestamp(jParser.getText());
System.out.println("Found created_time: " + jParser.getText());
list.add(o);
}
}
jParser.close();
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
{"data":[{"type": "photo"、 "link": "http://www.facebook.com/photo.php?fbid=10151331660204305&set=a.299455459304.180838.197394889304&type=1&relevant_count=1"、 " from ":{" name ":" FC Barcelona "、" category ":" Professional sports team "、" id ":" 197394889304 "}、" message ":"Puyolは8週間のレイオフに直面していますhttp://bit.ly/ QXhOFE \ r \ n \ r \ nPuyol、vuit setmanes de baixa http://bit.ly/T1enma\r\n\r\nPuyol、ocho semanas de baja http://bit.ly/T0eaj8 "、" picture " :"http://photos-g.ak.fbcdn.net/hphotos-ak-snc6/246623_10151331660204305_75156416_s.jpg"、 "created_time": "2012-10-03T17:40:06 + 0000"、 "id": " 197394889304_10151331937599305 "}、{" type ":" checkin "、"link": "http://www.facebook.com/pages/Hubben-21/249474758405147"、 "from":{"name": "Andreas Rol \ u00e9n"、 "id": "575703056"}、 "メッセージ":" En timme in i turneringen och redan chipleader "、" pictures ":" http://profile.ak.fbcdn.net/static-ak/rsrc.php/v2/y5/r/j258ei8TIHu.png "、 "name": "Hubben 2.1"、 "created_time": "2012-10-03T17:24:19 + 0000"、 "id": "575703056_10151181582028057"}、{"type": "photo"、 "link": " http://www.facebook.com/photo.php?fbid=10151445544542786&set=at.10151445533587786.588547.694032785.688088336&type=1&relevant_count=1 "、" from ":{" name ":" Jens Wilhelmsson "、" id ":" 688088336 「}、」写真":" http://photos-h.ak.fbcdn.net/hphotos-ak-prn1/72091_10151445544542786_676020840_s.jpg "、" created_time ":" 2012-10-03T17:21:40 + 0000 "、" id " :"688088336_10151111148358337"}、{"type": "link"、 "from":{"name": "Eric Lindqvist"、 "id": "648057222"}、 "created_time": "2012-10-03T17:20 :52 + 0000 "、" id ":" 648057222_10151249963167223 "}created_time ":" 2012-10-03T17:20:52 + 0000 "、" id ":" 648057222_10151249963167223 "}created_time ":" 2012-10-03T17:20:52 + 0000 "、" id ":" 648057222_10151249963167223 "}
Found type: photo
Found name: FC Barcelona
Found name: Andreas Rolén
Found name: Hubben 2.1
Found created_time: 2012-10-03T17:24:19+0000
Found type: photo
Found name: Jens Wilhelmsson
Found name: Eric Lindqvist