Error when converting from JSON String to Datatable

Feb 22, 2012 at 11:13 AM

Hi, I have a simple datatable that converts to the following json string when using fastjson :

txtJSon = {"$types":{"fastJSON.DatasetSchema, fastJSON, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null":"1"},{"$schema":"$type":"1","Info":["","Id","System.Int32","","Description","System.String","","BaseCurrenciesId","System.Int32","","ExternalBanks","System.Boolean"],"Name":""},"":[[3,"Barclays",139,true]]}

If I want to take the above json string and convert back to datatable using code :

where dt = datatable 

dt = fastJSON.JSON.Instance.ToObject(txtJSon)

 

dt = fastJSON.JSON.Instance.Parse(txtJSon)

I get the following error : Could not find token at index 108.

Please assist.

Tnx

Andy Fensham

Mar 5, 2012 at 9:08 PM

Same error (Could not find token at index 108) trying to deserialize.

It only works if I use the Return class, as in the examle code

                Return r = new Return();
                r.Name = "hello";
                r.Field1 = "dsasdF";
                r.Field2 = 2312;
                r.date = DateTime.Now;
                r.ds = ds.Tables[0];
 
                fastJSON.JSON.Instance.SerializeNullValues = true;
                fastJSON.JSON.Instance.ShowReadOnlyProperties = true;
                fastJSON.JSON.Instance.UseUTCDateTime = true;
                fastJSON.JSON.Instance.IndentOutput = false;
                fastJSON.JSON.Instance.UsingGlobalTypes = false;
                string ts = fastJSON.JSON.Instance.ToJSON(r);
                object tsd = fastJSON.JSON.Instance.ToObject(ts); 
Anybody?