Okay, so I have been searching everywhere on how to get my app to work. I have an app deployed on Tomcat. It needs to send an ArrayList of data as json preferably to an Android app. The app uses Volley API to get the response and I need to parse it back to the ArrayList. I have been asking everywhere I could, but haven't received any solid replies. Can someone give me links or pointers on how to achieve the aforementioned task?
Just to clarify: your Android app wants to use Volley to send a request to your web app. And it expects to receive a list of data encoded in JSON from the web app, and you want to decode that JSON data into a List. Right?
I did some searching the web and I found examples of Android code which use a "JsonRequest"; it sends a request and receives JSON as a response. I assume you found those examples too? So as I see it your question boils down to converting some JSON text into a Java List object. Which is independent of the fact that Volley sent the request and received the response. Am I right, or is there more to your question that that?
posted 11 months ago
Thanks for the reply Paul. Yes, that's exactly my doubt. I did find some examples and I'm trying them out right now. Like you said, I'm using JsonRequest.
Well, if you want to convert JSON to ArrayList (does it really have to be an ArrayList or will any List do?) then that doesn't sound like it's really Android-specific. I'll flag this thread to be in a general Java forum too, so it should be seen by more people.
In your app, I am assuming the web-app on the Tomcat server accepts the Android app's request and returns a JSON response - the resonse is received by the Android app.
To parse the response output (which is a JSON string) and build the data into an ArrayList, the following is the way to code. In this case I am assuming the response JSON string has Earthquake data from a geological website.
Here is some JSON string data to be converted to Java objects and then store them in a List: