Last night I kept getting JSON related errors, I looked at my java code that was using JSONObject to extract data. Below is what happened and what was learned from it to avoid wasting time (esp when you are burning the midnight oil)
Mistake: Instead of looking at how the data was being handled, once read it from the file, I kept looking at the JSON in the file.
I had JSON data in a text file and I was trying to parse through it. So during the initial code write up, I read the data and stored it all in a String and to be able to confirm that all the data is being read I reinserted the formatting to make it look like how it looked in the text file. I printed it and once satisfied that data was being read correctly, I moved on to implement further functionality .....without.... deleting the debug code.......and reusing the same string object to extract the needed data. Brilliant!!! ain't it.
lesson learned: comment or delete the debug code once its purpose is completed. Always look at how the data is being handled.
I had JSON data in a text file and I was trying to parse through it. So during the initial code write up, I read the data and stored it all in a String and to be able to confirm that all the data is being read I reinserted the formatting to make it look like how it looked in the text file. I printed it and once satisfied that data was being read correctly, I moved on to implement further functionality .....without.... deleting the debug code.......and reusing the same string object to extract the needed data. Brilliant!!! ain't it.
lesson learned: comment or delete the debug code once its purpose is completed. Always look at how the data is being handled.
No comments:
Post a Comment