开发者

JsonParseException: Failed parsing JSON source to Json

I am getting Json Parsing Exception

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

Error is:

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"}]

to Json


Your json contains a non utf8 characters. the ellipsis near Now…

If you remove it, it'll compile.


JSON Source you have posted is not correctly formatted, just add property name before your Source. It will run correctly. So your new source will be

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

and it will work correctly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜