KMatle Expert Licensed User Longtime User Dec 31, 2014 #1 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)
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)
Erel B4X founder Staff member Licensed User Longtime User Dec 31, 2014 #2 In most cases you should use NextObject. If there is a server error then the Job.Success will be false (assuming that the server is configured correctly). You shouldn't try to parse the error message as a json string. You can always test the first character. If it is { then you should use NextObject. Upvote 0
In most cases you should use NextObject. If there is a server error then the Job.Success will be false (assuming that the server is configured correctly). You shouldn't try to parse the error message as a json string. You can always test the first character. If it is { then you should use NextObject.