InterfaceConvertor.cs 577 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Web.Script.Serialization;
  6. namespace Bowin.Common.Linq
  7. {
  8. public static class InterfaceConvertor
  9. {
  10. private static JavaScriptSerializer serial = new JavaScriptSerializer();
  11. public static string ToJson(this object i)
  12. {
  13. return serial.Serialize(i);
  14. }
  15. public static T JSONStringToClass<T>(this string JsonStr)
  16. {
  17. T objs = serial.Deserialize<T>(JsonStr);
  18. return objs;
  19. }
  20. }
  21. }