Blame view

NetLib/MyJson.cs 852 Bytes
20c0108c   wutaian   xx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  using Newtonsoft.Json;
  using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Text;
  
  namespace NetLib
  {
      public class MyJson
      {
          public static string Serialize(object obj)
          {
              string res = "";
              try
              {
                  res = JsonConvert.SerializeObject(obj); 
              }
              catch (Exception ex)
              {
                  string s = ex.ToString();
              }
              return res;
          }
  
          public static T DisSerialize<T>(string str)
          {
              T res = default(T);
              try
              {
                  res = JsonConvert.DeserializeObject<T>(str);
              }
              catch (Exception ex)
              {
                  string s = ex.ToString();
              }
              return res;
          }
      }
  }