Ejemplo n.º 1
0
 public static string JSONEncode(UserData oData)
 {
     MemoryStream strmJSON = new MemoryStream();
     DataContractJsonSerializer oSer = new DataContractJsonSerializer(oData.GetType());
     oSer.WriteObject(strmJSON, oData);
     strmJSON.Flush();
     var strJASON = Encoding.UTF8.GetString(strmJSON.ToArray());
     return strJASON;
 }
Ejemplo n.º 2
0
        private void OnAddUserClicked(object sender, EventArgs e)
        {
            UserData oUser = new UserData();
            oUser.FirstName = "Rahul";
            oUser.LastName = "Muley";
            oUser.MiddleName = "Ramchandra";
            oUser.LoginID = "rahul.muley";
            oUser.Password = "******";
            oUser.Type = UserType.ADMIN;
            oUser.Identity = "FirstUser";

            string strJSON = BaseData.JSONEncode(oUser);

            UserData oUser2 = (UserData)BaseData.JSONDecode(typeof(UserData), strJSON);

            return;
        }