You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

25 lines
614 B

  1. package net.phalapi.sdk;
  2. import org.json.JSONObject;
  3. /**
  4. * JSON解析
  5. */
  6. public class PhalApiClientParserJson implements PhalApiClientParser {
  7. public PhalApiClientResponse parse(String apiResult) {
  8. if (apiResult == null) {
  9. return new PhalApiClientResponse(408, "", "Request Timeout");
  10. }
  11. try {
  12. JSONObject jsonObj = new JSONObject(apiResult);
  13. return new PhalApiClientResponse(
  14. jsonObj.getInt("ret"), jsonObj.getString("data"), jsonObj.getString("msg"));
  15. } catch (Exception ex) {
  16. return new PhalApiClientResponse(500, "", "Internal Server Error Or " + ex.getMessage());
  17. }
  18. }
  19. }