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.
 
 
 

47 lines
872 B

  1. using System;
  2. using SUISS.Cloud.Boomlagoon.JSON;
  3. namespace SUISS.Cloud
  4. {
  5. public class ApiResponse
  6. {
  7. public ApiResponse(object data)
  8. {
  9. this.Json = data;
  10. }
  11. public JSONValue Data
  12. {
  13. get
  14. {
  15. string text = SUISS.Cloud.Json.Encode(this.Json);
  16. text = text.Trim();
  17. if (!text.StartsWith("{") && !text.StartsWith("["))
  18. {
  19. return null;
  20. }
  21. if (text.StartsWith("{"))
  22. {
  23. JSONObject jsonobject = JSONObject.Parse(text);
  24. if (jsonobject == null)
  25. {
  26. return null;
  27. }
  28. return new JSONValue(jsonobject);
  29. }
  30. else
  31. {
  32. JSONObject jsonobject2 = JSONObject.Parse("{\"data\":" + text + "}");
  33. if (jsonobject2 == null)
  34. {
  35. return null;
  36. }
  37. return jsonobject2.GetValue("data");
  38. }
  39. }
  40. }
  41. public object Json { get; private set; }
  42. }
  43. }