ResponseStructure.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. namespace SuperCms.Models
  7. {
  8. public class ResponseStructure
  9. {
  10. public String code { get; set; }
  11. public String message { get; set; }
  12. public override string ToString()
  13. {
  14. return JsonConvert.SerializeObject(this);
  15. }
  16. public ResponseStructure() { }
  17. public ResponseStructure(string json) : this(JObject.Parse(json))
  18. { }
  19. public ResponseStructure(JObject jObject)
  20. {
  21. if (jObject != null)
  22. {
  23. code = (string)jObject["CODE"];
  24. message = (string)jObject["MESSAGE"];
  25. }
  26. }
  27. }
  28. public class ResponseStructures
  29. {
  30. [JsonProperty("data")]
  31. public List<ResponseStructure> data { get; set; }
  32. public override string ToString()
  33. {
  34. return JsonConvert.SerializeObject(this);
  35. }
  36. public ResponseStructures() { }
  37. public ResponseStructures(string json) : this(JObject.Parse(json)) { }
  38. public ResponseStructures(JObject jObject)
  39. {
  40. if (jObject != null)
  41. {
  42. var list = jObject["data"];
  43. if (list != null && list.HasValues)
  44. {
  45. data = new List<ResponseStructure>();
  46. JArray a = (JArray)list;
  47. foreach (JObject o in a.Children<JObject>())
  48. {
  49. data.Add(new ResponseStructure(o));
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }