简体   繁体   中英

Designing Different JSON Responses from a WebService in case of Error

I have an android client that searches for POI across a location. I currently parse the JSON using Jackson parser, so the return type of AsyncTask's DoInBackground is SearchResponse. But the problem happens when Error is returned from the server saying it could NOT connect to third party servers. In that case I want to return an Error something like ErrorResponse. One way is to implement a BaseResponse class and all responses (ErrorResponse,SearchResponse can extend from it) and have it as a return type. Is this the right way to do this? Can somebody suggest any better ways.

为什么在成功的情况下,为什么不仅包装消息中包含内容的节点,还包含错误ID /消息的节点?

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