android


Gson fromJson parsing a list sometimes returning null


I have an application communicating to a server through Json data. Sometimes the server answers back with a list of objects and the application parses the json string using the syntax :
List<My_Object_Type> list = new Gson().fromJson(json, new TypeToken<List<My_Object_Type>>() {}.getType());
Through my application log, i always print what the server answer in order to be able to check if everything is correct and diagnosis errors. Thus i'm able to see if the gson syntax is correct, if the server encountered a problem or...
The application works fine, almost 99% of the time, but in the little 1% remaining the json List is null. And that's not even a problem about the data structure, neither the json String because in the same application log i saw the exact same json line in the exact same query being answered, and there was no problem.
Question : if the gson deserialization is called on another Thread (asynTask), could it lead to it to fail deserializing ? I dont see any reason why the first call works, the second one too, but not the third one.
In order to further get any problem, I copy/past the Json string and directly called the deserialization through the exact same call (also copy/pasted)... And it worked.
Worked first --> no data structure error
Worked with copy/pasted string --> No string error
what could be other problems with deserialization ?
PS: I read other questions leading to "wrong json string" or "wrong object structure" and it seems not being the case as it worked with the exact same string before.... Of course, I could deal with the null variable and prevent problems, but as it does not take data sent by the server it may lead to inappropriate behaviors....

Related Links

Error broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.flagg327.guicomaipu (has extras) }
CurveTo and ContinueCurveTo not drawing properly
Set the position of a button in a layout via Java
Applock and android:noHistory=“true” conflicts
Can I connect more than two Computer to my single android device via adb (TCP/IP)?
Put all ongoing requests to queue retrofit and okhttp
Which API decides if the call is going through VoLTE or VoWiFi in Android?
WebVtt subtitles not displaying( not working)
Gallery Not Showing Content
Your APK's version code needs to be higher than xxx phonegap
Everyplay not working in android vesion 5.1
GoogleApi Real Time Multiplayer pushing updates
How to pass value from onItemSelected to another spinner
OnItemClickListener for horizontal gridview
Saving canvas draw in bitmap showing white screen
How to cut off an unused space in a custom view?

Categories

HOME
cheerio
developer-tools
phpmyadmin
angular2-material
camera
can
appcelerator
pdfbox
spring-data-mongodb
hugo
crystal-reports-2013
angularfire2
opengl-3
google-schemas
plist
project-intu
mxgraph
datastage
google-form
libc
libusb
glyphicons
scsi
esoteric-languages
null-pointer
boost-icl
visual-glitch
articulate-storyline
babel
event-store
fable-f#
intersystems-cache
handler
twiml
magento-1.8
scrollview
autodesk-designautomation
zend-debugger
rselenium
code-snippets
android-gridview
arduino-ide
docfx
cd
hackintosh
tasm
apriori
oracle-service-bus
http-request
fwrite
netbeans6.8
geotiff
lightning
context-switch
qtranslate
gpg-signature
docpad
iotivity
jodd
project-organization
jparsec
atan2
directdraw
include-guards
bufferedinputstream
zend-currency
showdialog
theos
deform
contrast
punycode
create.js
amslidemenu
xmltodict
http-patch
c++builder-xe5
ebay-lms
asdf
nebula
poker
bjyauthorize
sqlclr
nokia-s40
boost-msm
cakephp-1.2
iboutlet
flex-mobile
entity-attribute-value
event-receiver
nhprof
metaweblog
ajax-polling
eclipse-marketplace
blender-2.49
strtod
interop-domino
fault-tolerance
idatareader

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App