OpenFeign.cs 905 B

123456789101112131415161718192021222324252627
  1. using Common;
  2. using NuGet.DependencyResolver;
  3. namespace Util
  4. {
  5. /// <summary>
  6. /// Json任何类型读取到字符串属性
  7. /// 因为 System.Text.Json 必须严格遵守类型一致,当非字符串读取到字符属性时报错:
  8. /// The JSON value could not be converted to System.String.
  9. /// </summary>
  10. public class OpenFeign
  11. {
  12. public static T GetInfo<T>(string Url, string Param)
  13. {
  14. string ReturnData = Function.PostWebRequest(Url, Param);
  15. T Obj = Newtonsoft.Json.JsonConvert.DeserializeObject<T>(ReturnData);
  16. return Obj;
  17. }
  18. public static List<T> GetList<T>(string Url, string Param)
  19. {
  20. string ReturnData = Function.PostWebRequest(Url, Param);
  21. List<T> List = Newtonsoft.Json.JsonConvert.DeserializeObject<List<T>>(ReturnData);
  22. return List;
  23. }
  24. }
  25. }