Apr 24, 2010, 2:59 PM
[1.0] JSON Deserializer Error
Hey,
I start using Ext.Net from Scratch but using the same methdologies that I
have used with 0.8.2.
I'm getting actually a big problem with the deserialization process.
I'm using this code to get the data from a datasource and save my entity
wich is "Patient"
1- In 0.8.2 the e.ExtraParams["jsonEntity"] return the following string :
This is getting me crazy
Thanks a lot for you help !!
I start using Ext.Net from Scratch but using the same methdologies that I
have used with 0.8.2.
I'm getting actually a big problem with the deserialization process.
I'm using this code to get the data from a datasource and save my entity
wich is "Patient"
protected void SaveClick(object sender, AjaxEventArgs e)
{
Notification.Config myConfig = new Notification.Config();
myConfig.Icon = Icon.Information;
myConfig.Height = 80;
myConfig.Width = 230;
myConfig.Title = "Notification";
Patient Entity =
Newtonsoft.Json.JsonConvert.DeserializeObject<TList< Patient
>>(e.ExtraParams["jsonEntity"])[0];
TransactionManager tm =
DataRepository.Provider.CreateTransaction();
tm.BeginTransaction();
try
{
if (CurrentId.Text != "0")
{
Entity.Id = int.Parse(CurrentId.Text);
DataRepository.PatientProvider.Update(tm, Entity);
}
else
DataRepository.PatientProvider.Insert(tm, Entity);
myConfig.Html = string.Format("Enregistrement :
{0} a été sauvegardé avec succès", Entity.Nom);
CurrentId.Text = Entity.Id.ToString();
tm.Commit();
Ext.Notification.Show(myConfig);
}
catch (Exception ex)
{
if (tm != null && tm.IsOpen)
{
tm.Rollback();
Ext.MessageBox.Alert("Erreur", ex.Message).Show();
}
}
this code was working well in 0.8.2. But in 1.0 i GET THIS ERROR.Erreur du serveur dans l'application '/Test.Website'.
UNEXPECTED CHARACTER ENCOUNTERED WHILE PARSING
VALUE: <. LINE 1, POSITION 1.
Description : Une exception non gérée s'est produite au moment de l'exécution de la demande Web actuelle. Contrôlez la trace de la pile pour plus d'informations sur l'erreur et son origine dans le code.
Détails de l'exception: Newtonsoft.Json.JsonReaderException:
Unexpected character encountered while parsing value: <. Line 1, position 1.
Erreur source:
Ligne 98 : //Patient Entity = EntityHelper.DeserializeEntityXml<Patient>(myEntityValue);
Ligne 99 :
Ligne 100 : Patient Entity = JSON.Deserialize<Patient>(e.ExtraParams["jsonEntity"]);
Ligne 101 :
Ligne 102 :
Fichier source : c:\Users\melek\Documents\Visual Studio 2008\WebSites\Test.Website\Forms\PatientForm.aspx.cs
Ligne : 100
So, I tried to track the error and here you are what I found :1- In 0.8.2 the e.ExtraParams["jsonEntity"] return the following string :
[{"Id":0,"NumeroDossier":88877,"Nom":"dcfdsdcdscs","Prenom":"","Age":null,"Tel":null,"Gestite":null,"Parite":null,"Ivg":false,"Ga":false,"Fc":false,"Ge":false,"SafeNameTermeThOriqueSemaine":null,"SafeNameTermeThOriqueJour":null,"TermeEchographiqueSemaine":null,"TermeEchographiqueJour":null,"TypeProtocol":null,"DateFirstPrise":null,"NbTotalCytotec":null,"DateExpulsion":null,"DureeHospitalisation":null,"DureeAdmissionPrise":null,"Vertiges":false,"Vomissement":false,"TroubleTransit":false,"DouleurAbdominoPelvienne":false,"Fievre":false,"AutresEffet":"","Retention":false,"CytotecRetention":false,"AspirationRetention":false,"Echec":false,"ChgmProtocoleEchec":false,"AspirationEchec":false,"Saignement":false,"Endometrie":false,"Perforation":false,"PerforationSecondaire":false,"Fr":false,"Synechie":false,"AutresComplication":"","Atb":false,"Tetracycline":false,"BLactamine":false,"Ocytocine":false,"Methergin":false,"Contraception":false,"CycleArtificiel":false}]
2- In 1.0, the e.ExtraParams["jsonEntity"] return the following string :<Id>0</Id><NumeroDossier>0</NumeroDossier><Nom
/><Age>0</Age><Tel>0</Tel><Gestite>0</Gestite><Parite>0</Parite><Ivg>false</Ivg><Ga>false</Ga><Fc>false</Fc><Ge>false</Ge><SafeNameTermeThOriqueSemaine>0</SafeNameTermeThOriqueSemaine><SafeNameTermeThOriqueJour>0</SafeNameTermeThOriqueJour><TermeEchographiqueSemaine>0</TermeEchographiqueSemaine><TermeEchographiqueJour>0</TermeEchographiqueJour><TypeProtocol>0</TypeProtocol><DateFirstPrise
/><NbTotalCytotec>0</NbTotalCytotec><DateExpulsion
/><DureeHospitalisation>0</DureeHospitalisation><DureeAdmissionPrise>0</DureeAdmissionPrise><Vertiges>false</Vertiges><Vomissement>false</Vomissement><TroubleTransit>false</TroubleTransit><DouleurAbdominoPelvienne>false</DouleurAbdominoPelvienne><Fievre>false</Fievre><AutresEffet
/><Retention>false</Retention><CytotecRetention>false</CytotecRetention><AspirationRetention>false</AspirationRetention><Echec>false</Echec><ChgmProtocoleEchec>false</ChgmProtocoleEchec><AspirationEchec>false</AspirationEchec><Saignement>false</Saignement><Endometrie>false</Endometrie><Perforation>false</Perforation><PerforationSecondaire>false</PerforationSecondaire><Fr>false</Fr><Synechie>false</Synechie><AutresComplication
/><Atb>false</Atb><Tetracycline>false</Tetracycline><BLactamine>false</BLactamine><Ocytocine>false</Ocytocine><Methergin>false</Methergin><Contraception>false</Contraception><CycleArtificiel>false</CycleArtificiel>
So, HOW can I solve he problem please !!!This is getting me crazy
Thanks a lot for you help !!