I am trying to connect to a website. After While authentication is successful, I get the following response:
{"code": "OK",
"data": {"session_id": "apimanager@taurusseo.com:EdiPNoBS2iYxOsAF9e2ceMbk"},
"user": "apimanager@taurusseo.com"}
What is the quick and easy way to parse through the (pure text) response given above?
Also, if the response is a JSON object, then how do I parse through the response, preferably using GSON library? I just want to use a library that is supported by Google App Engine for Java and GSON is one of those.
Finally, if a response analogous to the above is an XML response, then do I have to model a struct that resembles the response above? Again, is there a quick and easy way to get the response and parse through it, preferably using XML RPC Client? Again, I just want to use a library that is supported by Google App Engine for Java. XML RPC client is just a suggestion, if you can suggest something better then kindly do so.
I am confused as to why you would get back different data types of responses for the same request. However, you should be able to inspect the Content-Type header of the response, to determine if you should parse it as JSON or XML. As you already mentioned, you could use a library such as Gson to handle the response as JSON, or one of the build-in XML APIs (eg JAXP) to handle the response as XML.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.