简体   繁体   中英

Android Volley get json Object from error responses ( !=200)

I have a bit nonstandard situation where server sends in case of error responses (500, 404, ..) also json Object inside of response. But I have a problem to get it in Volley. Is there any way how to parse it from headers ?

简单的解决方案是重写parseNetworkResponsemakeStringReq()

  1. HTTP error codes should not have data in the returned response

  2. you can as suggested before, extend Volley's Request and override the parseNetworkResponse and pass on the data if needed or do anything that is reqired.
    ps remember that it runs off the UI thread but is blocking a network thread, so you can do heavy parsing but should probably only figure out if this is a success or error and let the rest of the chain take care of parsing.

  3. You can also write your own ErrorListener and figure out what to do upon the different types of errors reponses

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM