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

Get and modyfy java source from my own ROM(GalaxyS2)?
using viewHolder Interface to update state to Listview
I want Drag and Drop to my Hsv Alert Dialog Color picker in Android
Rotate text when drawing it on a bitmap
How to provide consistent timing of audio sequencing across various Android devices and OS Versions?
Face detection on Samsung devices
Insert bitmap to sqlite database
Trying to append values to the textview from inside while loop
Delphi XE5 TIdUDPServer does not receive anything on Android
OnFocusChangeListener is repeating the previous Listener in Android
centering the camera in Google Maps V2
zoom in and zoom out animation in android
adb push <directory>, but skip .svn .git (and friends)
Text overflows on an EditTextPreference
onHoverListener doesn't work in Android
Android app start with XML animations crash

Categories

HOME
service-worker
fabricjs
phpword
porting
twitter-bootstrap-3
apache-flink
amp-html
android-studio-2.2
character-encoding
interface
package
vscode-extensions
opendj
carousel
data-visualization
spin
pcl-crypto
onedrive-api
azure-powershell
identity-management
gmm
postscript
pchart
exploit
monit
data.stackexchange.com
custom-post-type
bulletphysics
delimiter
oculus
ms-access-2003
underscore.js
android-things
winexe
errbot
record
slacktextviewcontroller
least-squares
git-rewrite-history
z-notation
odroid
tcc
zenhub
java-websocket
branch-prediction
javafx-css
vcloud-director-rest-api
grails-plugin
builtins
webjars
myspace
iotivity
resourcemanager
jquery-jscrollpane
design-principles
libvlc
atan2
vigenere
google-books
fuelcms
text-search
airbrake
graphics2d
apache-commons-daemon
kubuntu
jquery-forms-plugin
cbind
jama
template-deduction
gnumeric
authlogic
amslidemenu
mt4j
oocss
tlf
merb
insert-id
windows-98
bjyauthorize
curb
os.system
fitbounds
google-maps-mobile
procedures
role
user-tracking
mysql-error-1205
listactivity
clrstoredprocedure
quotation-marks
tmx
cdonts
presentation-layer
load-time
web-garden
purepdf
int64
entitykey
leader
netbeans6.1

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