PhalApiClientParserJson.cs 593 B

123456789101112131415161718192021222324
  1. using Newtonsoft.Json;
  2. using System;
  3. namespace PhalApiClientSDK
  4. {
  5. /**
  6. * JSON解析
  7. */
  8. public class PhalApiClientParserJson : PhalApiClientParser {
  9. public PhalApiClientResponse parse(String apiResult) {
  10. if (apiResult == null) {
  11. return new PhalApiClientResponse(408, "", "Request Timeout");
  12. }
  13. try {
  14. return JsonConvert.DeserializeObject<PhalApiClientResponse>(apiResult);
  15. } catch (Exception ex) {
  16. return new PhalApiClientResponse(500, "", "Internal Server Error: " + ex.Message);
  17. }
  18. }
  19. }
  20. }