2011-05-31 69 views
0

我得到JSON解析異常JsonParseException:無法解析JSON源到JSON

Type collectionType = new TypeToken<ArrayList<CGNotifications>>(){}.getType(); 
Notifications =gson.fromJson(result,collectionType); 

錯誤是:

com.google.gson.JsonParseException: Failed parsing JSON source: 


[{"strNotification":"Hey, Cricgamble has sent you Cash Pack. Play Cricgamble to accept this gift Now…","strNotificationID":"NF73542011530151117256"}, 


{"strNotification":"Opps, you have lost Next Wicket Method : Caught. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF98402011530141552451"}, 
{"strNotification":"Opps, you have lost Bowler To Get Next Wicket : T Dilshan. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF25002011530141551389"}, 
{"strNotification":"Opps, you have lost Next Wicket Method : Caught. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF40702011530141552467"}, 

{"strNotification":"Opps, you have lost Bowler To Take 2 Wickets : R Herath. Try your speculation in upcoming matches. CricGamble has withdrawn 1000 from your account.","strNotificationID":"NF40702011530141552467"}, 
{"strNotification":"Opps, you have lost Bowler To Take 2 Wickets : R Herath. Try your speculation in upcoming matches. CricGamble has withdrawn 1000 from your account.","strNotificationID":"NF32862011530141552529"}, 
{"strNotification":"Opps, you have lost Bowler To Take 2 Wickets : R Herath. Try your speculation in upcoming matches. CricGamble has withdrawn 1000 from your account.","strNotificationID":"NF58272011530141552498"}, 
{"strNotification":"Opps, you have lost Bowler To Take 2 Wickets : R Herath. Try your speculation in upcoming matches. CricGamble has withdrawn 1000 from your account.","strNotificationID":"NF90562011530141552514"}, 
{"strNotification":"Opps, you have lost Bowler To Take 2 Wickets : R Herath. Try your speculation in upcoming matches. CricGamble has withdrawn 1000 from your account.","strNotificationID":"NF72992011530141552483"}, 


{"strNotification":"Opps, you have lost Next Wicket Method : Caught. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF63272011530141552389"}, 
{"strNotification":"Opps, you have lost Next Wicket Method : Caught. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF98402011530141552451"}, 
{"strNotification":"Opps, you have lost Next Wicket Method : Caught. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF80842011530141552420"}, 
{"strNotification":"Opps, you have lost Next Wicket Method : Caught. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF92422011530141551467"}, 
{"strNotification":"Opps, you have lost Next Wicket Method : Caught. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF74852011530141551436"}, 
{"strNotification":"Opps, you have lost Next Wicket Method : Caught. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF42572011530141551420"}, 
{"strNotification":"Opps, you have lost Next Wicket Method : Caught. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF74852011530141551436"}, 

{"strNotification":"Opps, you have lost Next Batsman To Get Out : E Morgan. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF25002011530141551389"}, 
{"strNotification":"Opps, you have lost Next Batsman To Get Out : E Morgan. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF76722011530141550389"}, 

{"strNotification":"Opps, you have lost Next Wicket Method : Bowled. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF57292011530141551404"}, 

{"strNotification":"Opps, you have lost Bowler To Get Next Wicket : T Dilshan. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF57292011530141551404"}, 


{"strNotification":"Opps, you have lost Next Batsman To Get Out : E Morgan. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF70732011530141549405"}, 
{"strNotification":"Opps, you have lost Next Batsman To Get Out : E Morgan. Try your speculation in upcoming matches. CricGamble has withdrawn 100 from your account.","strNotificationID":"NF56012011530141549420"}] 

到JSON

+0

https://androidbeasts.wordpress.com/2015/08/04/json-parsing-tutorial/:Checkout following link。 – Aakash 2015-08-05 15:09:50

回答

0

您的JSON包含非UTF8字符。 現在附近的省略號...

如果您刪除它,它會編譯。

0

您發佈的JSON源格式不正確,只需在您的源代碼之前添加屬性名稱即可。它會正確運行。 因此新的來源將是

newSource = " { \"propertyName\" : " + oldSource + " } "; 

,它會正常工作。