iwanttogetdatafromphpfiletoandroidusingjson.this is my code :
.
HttpEntity e=r.getEntity (;
string data=entity utils.tostring (e;
返回最后;
whenidebugtheprogramthereisjsonexceptiononthisline :
Data is {'a':1,' b':2,' c':3,' d':4,' e ' :5 } and the exception is 3:
org.JSON.JSON exception : value { ' d ' :4,' e':5,' b':2,' c':3, ' a ' :1 } oftypeorg.JSON.jsonobjectcannotbeconvertedtosdfh/pheexceptionmessageisquiteeexplicitandalookatthejsonsyntathed
{'a':1,' b':2,' c':3,' d':4,' e':5}
This string represents an object,nota narray.anexampleofanarraywouldbethis :
or even this:
notethatstartingandclosingbrackets。
ithinkthatyouwillfindthattheexceptionlocationisslightlymisleading.id on ' tknowifisaresultofsomesortoflazyinitialiononononorsssssssleationg
sincethedatastringrepresentsajsonobjectandnotanarray,thisoperationisclearlyimpossible。