我使用GSON在JSON解析問題JsonParseException在使用JSON解析GSON
我的JSON文本是
{
**"message": [**
{
"id": "123",
"trackid": "GPN-GET-HYGH",
"category": "0",
"subject": "new message",
"dt": "2013-04-02 14:52:48",
**"message": "Hewlrj",**
"repliername": null,
"attachment_name": "image.jpg"
}
],
"replies": [
{
"id": "165",
"replyto": "123",
"name": "962788161885",
"message": "Hellooo\nHjkhjkhjkhkjh\nHjkhkjhjkhkh",
"dt": "2013-04-02 15:53:11",
"attachments": "",
"staffid": "0",
"rating": null
}
]
}
我已經創建了兩個階級一個消息和第二的答覆與上述領域
但得到的異常
com.google.myjson.JsonParseException: Expecting object found: "Hewlrj"
請幫我
EDITED
我的消息類結構看起來像(無吸setter..i已將其刪除)
public class message {
int id;
String trackid;
String category;
String subject;
String dt;
String message;
String repliername;
String attachment_name;
}
public class TicketList {
ArrayList<message> message;
}
try{
Gson json=new Gson();
object=json.fromJson(mJSONString,TicketLis.class);
}catch (Exception ex) {
System.out.println("error in gson parsing");
ex.printStackTrace();
}
消息和回覆不應該是類。他們應該是一個arraylist和ArrayList –
rgksugan
2013-04-04 09:40:29
@ rgksugan你是對的,它是我的錯,寫的問題,我已經創建了第三類的消息和回覆列表 – Android 2013-04-04 09:42:25
@rgksugan如果那些不是類,那麼如何可以生成帶有消息的ArrayList和回覆對象? – 2013-04-04 09:43:37