2011-05-31 95 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 + " } "; 

,它会正常工作。