Json反序化
Dictionary<string, object> dictionary = JSONToObject<Dictionary<string, object>>(Str);
public static T JSONToObject<T>(string jsonText) { T local; JavaScriptSerializer serializer = new JavaScriptSerializer(); try { local = serializer.Deserialize<T>(jsonText); } catch (Exception exception) { throw new Exception(exception.Message); } return local; } |
public static string ObjectToJSON(object obj) { string str; JavaScriptSerializer serializer = new JavaScriptSerializer(); try { str = serializer.Serialize(obj); } catch (Exception exception) { throw new Exception(emYpxP33xAq8jO8oJ1.eopWKtZX1(0) + exception.Message); } return str; } |
|