Android Question Httputils: Job.GetString & JSON Parser: Check type of data coming back

KMatle

Expert
Licensed User
I use the JSON Parser to parse data coming back (=Job.GetString) from my php scripts.

The parser has 3 methods:

- nextvalue
- nextarray
- nextobject

Sometimes you don't know which format is coming back (f.e. MySql errors which are not handled in the php or php typos) and the app is throwing an exeption for not using the right method (f.e. nextvalue when an array comes back).

Question: What is the best practice to check what kind of data is coming back to know which method to call? Of course I can handle it by code (check first bytes or so but I don't feel well about it)
 
Top